Attributs: fonction removeAttr

Supprime un attribut des éléments concernés.

Version: disponible depuis la version 1.0 de JQuery

Paramétres:

  • nom (String): nom de l'attribut a supprimer

Valeur de retour: objet jQuery

Exemple :

Supprime l'attribut "disabled" du champ input.

$("button").click(function () {
      $(this).next().removeAttr("disabled")
             .focus()
             .val("de nouveau editable");
    }
);
  <html>
  <head>
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
  <script type="text/javascript">
  	$(document).ready(function(){
  		$("button").click(function () {
      $(this).next().removeAttr("disabled")
             .focus()
             .val("de nouveau editable");
    }
);

  	});
  </script>
  
  <style>
  
  </style>
  </head>
  <body>
  	<button>Activer</button>
  <input type="text" disabled="disabled" value="champ non éditable" />

  </body>
  </html>

0 Commentaire (afficher/poster)