Skip to content

Instantly share code, notes, and snippets.

@jbuncle
Created May 19, 2016 12:20
Show Gist options
  • Save jbuncle/c172263ed82db83c5f560b0bdc885011 to your computer and use it in GitHub Desktop.
Save jbuncle/c172263ed82db83c5f560b0bdc885011 to your computer and use it in GitHub Desktop.
jQuery plugin example of checking if an element has a given attribute
(function ($) {
$.fn.hasAttr = function (name) {
var currentAttr = $(this).attr(name);
return currentAttr !== undefined && currentAttr !== false;
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment