Hello All, We are going to start new batch from next week. message/call or mail us for more details.

7 September 2013

JQuery removeAttr () method

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>
 
    <script type="text/javascript" src="jquery.min.js">//add jquery library in script tag
    </script>
 
    <script type="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>
    <table width="275" border="2" >         <tr>
            <td align="center">
               <label>Name</label>
            </td>
            <td align="center">
                <input type="text" style="color: Red">
            </td>
          </tr>
           <tr>
            <td align="center">
                <label>Age</label>
            </td>
            <td align="center">
                <input type="text" style="color: Red">
            </td>
          </tr>
           <tr>
            <td align="center">
               <label>City</label>
            </td>
            <td align="center">
                <input type="text" style="color: Red">
            </td>
          </tr>
           <tr>
            <td align="center">
                <label>College</label>
            </td>
            <td align="center">
                <input type="text" style="color: Red">
            </td>
          </tr>
    </table>
    <button>
        Submit</button>
    &nbsp;&nbsp; <button id="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

No comments:

Post a Comment