js/helpers: add $.hasAttr

Need this for another fix and there is no such jQuery function. As this
seems to also be inconsistant across browsers I thought this would
definitively be worth a custom jQuery plugin.
This commit is contained in:
Thomas Gelf 2014-08-19 12:22:36 +02:00
parent 0d3fb9e7a5
commit 9ce99bf280
1 changed files with 7 additions and 0 deletions

View File

@ -95,6 +95,13 @@ if (!Function.prototype.bind) {
'use strict';
/* Whether a HTML tag has a specific attribute */
$.fn.hasAttr = function(name) {
// We have inconsistent behaviour across browsers (false VS undef)
var val = this.attr(name);
return typeof val !== 'undefined' && val !== false;
};
/* Get class list */
$.fn.classes = function (callback) {