js: Add new jQuery plugin `getData()`
This commit is contained in:
parent
9e3c9bbab7
commit
27cd34dd2d
public/js
|
@ -5,6 +5,16 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
/* Get data value or default */
|
||||||
|
$.fn.getData = function (name, fallback) {
|
||||||
|
var value = this.data(name);
|
||||||
|
if (typeof value !== 'undefined') {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fallback;
|
||||||
|
};
|
||||||
|
|
||||||
/* Whether a HTML tag has a specific attribute */
|
/* Whether a HTML tag has a specific attribute */
|
||||||
$.fn.hasAttr = function(name) {
|
$.fn.hasAttr = function(name) {
|
||||||
// We have inconsistent behaviour across browsers (false VS undef)
|
// We have inconsistent behaviour across browsers (false VS undef)
|
||||||
|
|
Loading…
Reference in New Issue