js中的getAttribute()
来源:互联网 发布:二级c语言成绩查询时间 编辑:程序博客网 时间:2024/06/07 18:56
- getAttribute()是HTML DOM的一个方法,用以获取HTML元素的属性(如id,name,type以及其他自定义属性)。同理,setAttribute()、removeAttribute()都是对HTML元素的属性进行操作。
- style是HTML DOM的一个关于样式的对象,style对象的属性(如background,color,border等等)用以设置元素的样式。
- 举例说明:
<input type="text" id="btn" style="background-color: red">
- 获取type属性可以用: document.getElementById("btn").getAttribute("text"); //注意要获取的属性有双引号
- 获取元素样式可以用: document.getElementById("btn").style.backgroundColor;
- 注: 如果属性是内联样式,也可直接用getAttribute()来获取其属性,但只能获取style,无法设置style里面具体的background-color里面具体的值。
阅读全文
0 0
- js中的getAttribute()方法
- js中的getAttribute()
- Js:getAttribute
- HTML中的JS代码getAttribute();返回一直为null
- js getAttribute()用法, javascript getAttribute()用法
- JavaScriPt中的getAttribute()方法
- JS getAttribute方法的使用
- jsp 中的getParameter和getAttribute
- java中的getAttribute和getParameter
- js中setAttribute()和getAttribute()用法
- JS之dom操作getAttribute()方法
- js onchange事件,以及setAttribute,getAttribute
- js-getAttribute与setAttribute的用法
- js 中getAttribute和setAttribute属性
- request中的request.getParameter()和getAttribute()
- MyHandler.h中的全局函数GetAttribute
- js变量使用request.getAttribute方法注意null的问题
- js 获取和设置 元素 属性 getAttribute setAttribute
- 算法面试100题——1、把二元查找树转变成排序的双向链表
- python 的字符串格式判断
- TAL好未来秋招编程题
- 深入Java单例模式
- PHP如何提高性能(分析)
- js中的getAttribute()
- LoadRunner脚本编写
- spring boot war 打包
- Android Jpush 6009错误代码解决方案
- onmousedown与onmouseup及onclick事件示例
- mergr into 在oracle中替代insert或update
- mysql中几个不用结尾符号也能够执行的语句
- 判断某年某月有多少天
- MySQL DBA的修炼与未来,看看老司机们怎么说?