articles

Home / DeveloperSection / Articles / jQuery removeAttr () method

jQuery removeAttr () method

Sachindra Singh11052 21-Feb-2011

In JQuery removeAtrr () method is used to remove attributes from each matched elements. By using this method  we can create some custom attribute and remove  attributes in element .In this article I am trying to show you, how we can use removeAttr () method to remove attributes of element on page as shown below:

Syntax :$( “element”).removeAttr (“name”);

Code:
<title>JQuery removeAtrr method</title>
 
    <scripttype="text/javascript"src="jquery.min.js">//add jquery library in script tag
    </script>
 
    <scripttype="text/javascript">
        $(document).ready(function() //ready function contain all jquery function
        {
            $("#rcolor").click(function()            {
                $("input").removeAttr("style");//removeAttr method will remove style attribute from all input tags
            });
        });
    </script>
</head>
<body>
    <tablewidth="275"border="2">         <tr>
            <tdalign="center">
               <label>Name</label>
            </td>
            <tdalign="center">
                <inputtype="text"style="color: Red">
            </td>
          </tr>
           <tr>
            <tdalign="center">
                <label>Age</label>
            </td>
            <tdalign="center">
                <inputtype="text"style="color: Red">
            </td>
          </tr>
           <tr>
            <tdalign="center">
               <label>City</label>
            </td>
            <tdalign="center">
                <inputtype="text"style="color: Red">
            </td>
          </tr>
           <tr>
            <tdalign="center">
                <label>College</label>
            </td>
            <tdalign="center">
                <inputtype="text"style="color: Red">
            </td>
          </tr>
    </table>
    <button>
        Submit</button>
    &nbsp;&nbsp;<buttonid="rcolor">
        Remove Color</button><!—button element with id-->
</body>
Screenshot

jQuery removeAttr () method

If we want to remove font color from textboxes click on remove color button and red color will remove from font as shown below:

jQuery removeAttr () method

 


Updated 07-Sep-2019

Leave Comment

Comments

Liked By