Skip to content

Instantly share code, notes, and snippets.

@kovaldn
Created July 26, 2013 06:53
Show Gist options
  • Save kovaldn/6086826 to your computer and use it in GitHub Desktop.
Save kovaldn/6086826 to your computer and use it in GitHub Desktop.
JavaScript: prop & attr.js
// СВОЙСТВА И АТРИБУТЫ: 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