Skip to content

Instantly share code, notes, and snippets.

@kickboxer
Forked from kovaldn/JavaScript: prop & attr.js
Last active August 29, 2015 14:14
Show Gist options
  • Save kickboxer/8747506317d0c53f6798 to your computer and use it in GitHub Desktop.
Save kickboxer/8747506317d0c53f6798 to your computer and use it in GitHub Desktop.
// СВОЙСТВА И АТРИБУТЫ: prop and attr
// =======================================
// PROP - для disabled
// правильно
$("input").prop('disabled', true);
$("input").prop('disabled', false);
// не правильно!
// $("input").attr('disabled','disabled');
// $("input").removeAttr('disabled');
// если только один элемент, то быстрее будет:
this.disabled = true;
// =======================================
// ATTR - для class, title и пр.
$("div").attr({"class":"divEl", "title":"Див"})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment