Skip to content

Instantly share code, notes, and snippets.

@blubbll
Last active October 21, 2018 03:49
Show Gist options
  • Select an option

  • Save blubbll/c2bc4ae0fd4d0d1c4e9696dce4e439b5 to your computer and use it in GitHub Desktop.

Select an option

Save blubbll/c2bc4ae0fd4d0d1c4e9696dce4e439b5 to your computer and use it in GitHub Desktop.
jQuery addAttr / has Attr
//jQuery extenden
jQuery.fn.extend({
addAttr: function(arg) {
$(this).is("[" + arg + "]") || $(this).attr(arg, "");
return this;
},
hasAttr: function(arg) {
return ($(this).is('[' + arg + ']'));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment