Home >Web Front-end >JS Tutorial >How to remove specified attributes from td elements in jquery
In jquery, you can use the removeAttr() method to remove the specified attribute in the td element. The function of this method is to remove the specified attribute from all matching elements. The specific syntax is "$(" td").removeAttr("Attribute to be removed")".
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
In jquery, you can use the removeAttr() method to remove the specified attribute in the td element.
removeAttr() method can remove the specified attribute from all matching elements.
Syntax:
$(selector).removeAttr(attribute)
attribute: Specifies the attribute to be removed from the specified element and cannot be omitted.
Example: Remove the id attribute in the td element
<!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>
Related tutorial recommendations:jQuery video tutorial
The above is the detailed content of How to remove specified attributes from td elements in jquery. For more information, please follow other related articles on the PHP Chinese website!