如何从javascript中设置html表单的属性

how to set attribute of html form from javascript

本文关键字:html 表单 属性 设置 javascript      更新时间:2023-09-26

我想将文本元素的属性从必需更改为不必需。我使用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