tadam logo
Did you find an error in the text?
Select this with mouse and press
Ctrl + Enter
Xhtml.co.il Check Spelling
Orphus system

removeAttr()

.removeAttr( attributeName )

Returns: jQuery

Description: Remove an attribute from each element in the set of matched elements.

.removeAttr( attributeName )

version added: 1.0
attributeName
An attribute to remove.

The .removeAttr() method uses the JavaScript removeAttribute() function, but it has the advantage of being able to be called directly on a jQuery object and it accounts for different attribute naming across browsers.

Examples

Clicking the button enables the input next to it.
    $("button").click(function () {
      $(this).next().removeAttr("disabled")
             .focus()
             .val("editable now");
    });

The output of the code above will be:
Full source:
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>  
  <script>
  $(document).ready(function(){    
    $("button").click(function () {
      $(this).next().removeAttr("disabled")
             .focus()
             .val("editable now");
    });
  });
  </script>
</head>
<body>
  <button>Enable</button>
  <input type="text" disabled="disabled" value="can't edit this" />
</body>
</html>
Was this information helpful?
   

Comments