jQuery.isElement(element,type)
Utility to find the Node type of an element.
by Avinash_R
JavaScript
(function($) {
$.extend({
isElement: function(element, type) {
if ($.isArray(element)) {
element = element[0];
}
if (typeof type === 'string') {
var nodeName = element.nodeName;
return nodeName && nodeName.toLowerCase() === type.toLowerCase();
}
return false;
}
});
$.fn.isElement = function(type) {
return $.isElement(this, type);
};
})(jQuery);
var x = $('<div>');
console.log($.isElement(x, 'div'));
console.log($.isElement(x, 'span'));
console.log(x.isElement('div'));
console.log(x.isElement('span'));