Created
June 18, 2015 09:35
-
-
Save dented/323417db552598036ebd to your computer and use it in GitHub Desktop.
Has Attribute check in JavaScript on jQuery or Native
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
define([], function (nb) { | |
'use strict'; | |
var hasAttribute = function(obj, prop) { | |
if (obj instanceof jQuery) { | |
if(obj.length > 1) throw "jQuery Array passed in"; | |
obj = obj[0]; | |
} | |
return !!obj.getAttribute(prop); | |
}; | |
return hasAttribute; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment