JS getAttribute和setAttribute(取得和设置属性)的使用介绍
2013-07-10 00:00
721 查看
getAttribute:取得属性;
setAttribute:设置属性;
setAttribute:设置属性;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <script language="JavaScript"> function change() { var input = document.getElementById("li1"); alert(input.getAttribute("title")); input.setAttribute("title", "mgc"); alert(input.getAttribute("title")); } </script> </head> <body> <ul id="u"> <li id="li1" title="hello">Magci</li> <li>J2EE</li> <li>Haha!</li> </ul> <input type="button" value="Change" onClick="change();" /> </body> </html>
相关文章推荐
- JS getAttribute和setAttribute(取得和设置属性)的使用介绍
- JS getAttribute和setAttribute(取得和设置属性)的使用介绍
- JS使用xxx.index=0 和 xxx.setAttribute(‘index’,0) 这两种设置自定义属性的区别?
- js将控件隐藏及display属性的使用介绍
- 使用js设置element的属性
- js document.getElementsByClassName的使用介绍与自定义函数
- 怎样用js取得/设置表格的所有属性?
- getAttribute:取得属性; setAttribute:设置属性。
- JS.GetAllChild(element,deep,condition)使用介绍
- JS.getTextContent(element,preformatted)使用介绍
- JS.getTextContent(element,preformatted)使用介绍
- Yii——使用CHtml::link()等方法时,设置htmlOptions属性可快速生成js代码和ajax请求
- js中用setAttribute为标签设置class属性
- JS.GetAllChild(element,deep,condition)使用介绍
- js修改原型的属性使用介绍
- 怎样用js取得/设置表格的所有属性?
- jdom中使用setAttribute(Attribute attribute)方法设置属性的注意事项
- masterpage中服务器端控件命名规则和如何用控件名取得document中的对象,用js动态设置控件事件和属性
- 【封装】java中为什么要将属性进行私有化,又使用set和get方法来设置和获取属性呢?
- 使用变量动态设置js的属性名