JavaScript 更改 HTML 属性值
<button onclick="document.getElementById('myImage').src='https://img.8i5.net/image/bulboff.gif'">Turn on the light</button>
<img id="myImage" src="https://img.8i5.net/image/bulboff.gif" style="width:100px">
<button onclick="document.getElementById('myImage').src='https://img.8i5.net/image/bulboff.gif'">Turn off the light</button>
JavaScript 更改了标记的src
(source) 属性的值:<img>
示例:

🏆 每日挑战:你知道答案吗?
如何在 CSS 中实现响应式字体?
温馨提示 : 非特殊注明,否则均为©李联华的博客网原创文章,本站文章未经授权禁止任何形式转载;IP地址:3.149.255.21,归属地:俄亥俄州Dublin ,欢迎您的访问!
文章链接:https://www.lilianhua.com/javascript-changes-the-html-attribute-value.html
文章链接:https://www.lilianhua.com/javascript-changes-the-html-attribute-value.html