我想将文本元素的属性从必需更改为不需要。我正在使用javascript来做到这一点。我正在基于单选按钮的输入调用函数,并且我使用的是HTML 5。
最佳答案
document.getElementById("adiv").removeAttribute("style")
document.getElementById("myimage").setAttribute("src","another.gif")
var getvalue=document.getElementById("myimage").getAttribute("src")
现在,但将其用作函数并按您的意愿使用它。
这就是在JavaScript中设置和删除属性的方式。
资料来源:http://www.javascriptkit.com/dhtmltutors/domattribute.shtml