在jquery中,可以使用removeAttr()方法来移除td元素中的指定属性。
removeAttr() 方法可以从所有匹配的元素中移除指定的属性。
语法:
$(selector).removeAttr(attribute)
-
attribute :规定从指定元素中移除的属性,不可省略。
示例:移除td元素中的id属性
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <script src="js/jquery-1.10.2.min.js"></script> <script type="text/JavaScript"> $(document).ready(function() { $("button").click(function() { $("td").removeAttr("id") }); }); </script> <style> #Peter{ background-color: #FFC0CB; } </style> </head> <body> <table border="1"> <caption>人物信息</caption> <tr> <th>姓名</th> <th>年龄</th> </tr> <tr> <td id="Peter">Peter</td> <td>20</td> </tr> <tr> <td>Lois</td> <td>20</td> </tr> </table><br /> <button>移除td中的id属性</button> </body> </html>
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)