我正在使用Javascript来更改HTML属性,在我的情况下,我有两个相同灯泡开关的照片,我使用2个按钮以“开启”和“关闭”灯泡,但现在我想将这两个按钮替换为第一个图像中开启的同一开关的两个图像,以及第二个图像中开关关闭的图像,如何操作?JavaScript:更改HTML属性
<!DOCTYPE html>
<html>
<body>
<h1>What Can JavaScript Do?</h1>
<p>JavaScript can change HTML attributes.</p>
<p>In this case JavaScript changes the src (source) attribute of an image.</p>
<button onclick="document.getElementById('myImage').src='pic_bulbon.gif'">Turn on the light</button>
<img id="myImage" src="pic_bulboff.gif" style="width:100px">
<button onclick="document.getElementById('myImage').src='pic_bulboff.gif'">Turn off the light</button>
</body>
</html>
的可能的复制[如何添加/更新使用JavaScript的HTML元素的属性?](http://stackoverflow.com/questions/710275/how-to-add-update-an -attribute-to-html-element-using-javascript) –