简体   繁体   English

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

[英]how to set attribute of html form from javascript

i want to change the attribute of a text element from required to not required. 我想将文本元素的属性从必需更改为不需要。 I am using javascript to do this. 我使用javascript来做到这一点。 i am calling a function based on the input of the radio button and i am using html 5.. 我正在调用基于单选按钮输入的功能,我正在使用html 5 ..

document.getElementById("adiv").removeAttribute("style")

document.getElementById("myimage").setAttribute("src","another.gif")

var getvalue=document.getElementById("myimage").getAttribute("src")

Now but it in a function and use it how you wish. 现在,但它在一个功能中,并按照您的意愿使用它。

That is how you get set and remove attributes in JavaScript. 这就是你在JavaScript中设置和删除属性的方法。

Source: http://www.javascriptkit.com/dhtmltutors/domattribute.shtml 资料来源: http//www.javascriptkit.com/dhtmltutors/domattribute.shtml

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM