Skip to content

Instantly share code, notes, and snippets.

@dented
Created June 18, 2015 09:35
Show Gist options
  • Save dented/323417db552598036ebd to your computer and use it in GitHub Desktop.
Save dented/323417db552598036ebd to your computer and use it in GitHub Desktop.
Has Attribute check in JavaScript on jQuery or Native
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