JS在EditPus中无法通过getAttribute()获取class属性---解决办法
来源:互联网 发布:java.util 编辑:程序博客网 时间:2024/06/03 13:48
直接上原始的代码
<html> <head> <title> JS中getAttribute方法 </title> </head> <body> <input type="text" class = "textclass" name ="inputtext" value="123"/> </body> <script type="text/javascript"> var i = document.getElementsByName("inputtext")[0]; alert(i.getAttribute("class")); </script></html>
无法获取到input标签中class属性值
问题原因是EditPlus默认是使用IE,所以要获取class属性,可用classname属性来替代。element.getAttribute(“classname”)来获取。
<html> <head> <title> JS中getAttribute方法 </title> </head> <body> <input type="text" class = "textclass" name ="inputtext" value="123"/> </body> <script type="text/javascript"> var i = document.getElementsByName("inputtext")[0]; alert(i.getAttribute("classname")); </script></html>
可以获取到class属性
0 0
- JS在EditPus中无法通过getAttribute()获取class属性---解决办法
- 忆龙2009:在IE下getAttribute()方法无法读到class属性的解决方法
- 原生Js通过class属性值获取对象
- js 中getAttribute和setAttribute属性
- js 中设置或获取自定义属性的方法setAttribute getAttribute attributes
- getAttribute获取属性值
- getAttribute()获取属性
- js 获取和设置 元素 属性 getAttribute setAttribute
- 在url中通过属性名获取属性值
- Android 在webview中 js弹窗无法弹出解决办法
- js根据class属性获取所有标签
- echarts 无法获取属性“getAttribute”的值: 对象为 null 或未定义 错误解决方法
- 使用js在IE9中获取标签自定义属性
- jsp中通过c set 保存值,在jsp中通过request getattribute 取值
- Js:getAttribute 取html中某个元素属性的值 或者设置添加属性和值
- 20、H5新增js属性之获取class列表属性
- 获取和设置属性getAttribute、setAttribute
- javascript 获取和设置属性getAttribute setAttribute
- 第二章 IoC 之 2.2 IoC容器基本原理
- iOS Info.plist文件
- @interface in .m file
- 初学unity3D-2016/01/18
- Atitit. servlet 与 IHttpHandler ashx listen 和HttpModule的区别与联系 原理理论 架构设计 实现机制 java php c#.net j
- JS在EditPus中无法通过getAttribute()获取class属性---解决办法
- U3D大师练成记之小白篇(一)
- 使用常见的网络命令查看当前网络状态——Mac OS X篇
- SalesForce
- Java 多态
- viewpager左右滑动的 +Tab指示(方式4-------------ViewPager+ViewPagerIndicator)
- 分享我创业4年失败的经历
- 超精密的iOS笔记.pdf
- HDU 1195 - Open the Lock