Created
May 19, 2016 12:20
-
-
Save jbuncle/c172263ed82db83c5f560b0bdc885011 to your computer and use it in GitHub Desktop.
jQuery plugin example of checking if an element has a given attribute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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