Javascript examples for jQuery Method and Property:removeAttr
The removeAttr() method removes one or more attributes from the selected elements.
Parameter | Require | Description |
---|---|---|
attribute | Required. | one or more attributes to remove. |
To remove several attributes, separate the attribute names with a space
The following code shows how to Remove the style attribute from all <p> elements:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("p").removeAttr("style"); });/*from w w w. j a v a 2s .c om*/ }); </script> </head> <body> <p style="font-size:120%;color:red">This is a paragraph.</p> <p style="font-weight:bold;color:blue">This is another paragraph.</p> <button>test</button> </body> </html>