您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

JQUERY通过当前标签名获取属性的值

2026/1/18 4:19:22发布23次查看
这次给大家带来jquery通过当前标签名获取属性的值,jquery通过当前标签名获取属性值的注意事项有哪些,下面就是实战案例,一起来看一下。
废话不多说了,具体代码如下所示:
<html>  <head>   <script type="text/javascript" src="jquery-1.10.2.min.js"></script>   <script type="text/javascript">    /** jquery 通过当前标签属性名,获取属性的值 */    function attrsbyjquery(obj){     var v1 = $(obj).attr(dbname);     var v2 = $(obj).attr(name);     alert(v1);     alert(v2);    }        /** javascript 通过当前标签属性名,获取属性的值 */    function attrsbyjs(obj){     var v1 = obj.getattribute('name');     var v2 = obj.getattribute('dbname');     alert(v1);     alert(v2);    }        function attrsbuttons(obj){     var v = obj.getattribute('name');     var vv = $(obj).attr(myname);     alert(v);     alert(vv);    }       </script>  </head>  <body>   <p>    <p style="width: 100px;height: 30px;float:left; margin-left:30px;" name="this is name feild" dbname="oracle1" onclick="attrsbyjs(this)">javascript</p>    <p style="width: 100px;height: 30px;float:left; margin-left:30px;" name="this is name feild" dbname="oracle2" onclick="attrsbyjquery(this)">juqery</p>    <input type="button" name="abcdeg" myname="this is my name" onclick="attrsbuttons(this)" value="buttons">   </p>  </body> </html>
相信看了本文案例你已经掌握了方法,更多精彩请关注其它相关文章!
推荐阅读:
js推拉门效果的实现
vue router+vuex实现后退状态保存
bootstrap实现上传文件时显示进度
以上就是jquery通过当前标签名获取属性的值的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product