I created a custom jquery event called \'loading\' in my application. I want to append a masking element with a spinner, when this event is triggered. I can figure out tha
You have to check the name:
/*global $, jQuery */
function isVoid(el) {
var tags = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input',
'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr'],
i = 0,
l,
name;
if (el instanceof jQuery) {
el = el[0];
}
name = el.nodeName.toLowerCase();
for (i = 0, l = tags.length; i < l; i += 1) {
if (tags[i] === name) {
return true;
}
}
return false;
}
And use it like this:
var el = document.getElementById('el'),
elj = $('#el');
if (!isVoid(el)) {
// append
}