Introduction:

Here we are going to explain what is removeAttr() function or how to use removeAttr() function or why use removeAttr() function or how to remove attribute of the selected elements  in jQuery with example.

Description: 

The jQuery removeAttr() function is used to remove attribute of the selected html elements.   


Syntax:

To remove an attribute:

$(selector).removeAttr(attribute)

 

  • Example of jQuery removeAttr() function

Let's see an example to of jQuery removeAttr() function.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>jquery removeAttr tutorial</title>
    <script src="Scripts/jquery-1.8.2.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("button").click(function () {
                $("p").removeAttr("style");
            });
        });
    </script>
 
</head>
<body>
    
    <p style="background-color:yellow;">SQL Tutorials Point</p>
    <button>Remove style attribute</button>
</body>
</html>

 

 As shown in the above program, when user click on button then remove the style attribute of p element.


Output:



I hope it will help to you.

 

0 comments


Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

Welcome to SQL Tutorials Point

Don't have an account? Click here to Create a new account, it takes less than a minute.