/*
** Matt Kruse's hasClass, with slight modification
** Determine if an object or class string contains a given class.
*/
function hasClass (obj, className) {
if (typeof obj == 'undefined' || obj==null || !RegExp) { return false; }
var re = new RegExp("(^|s)" + className + "(s|$)");
if (typeof(obj)=="string") {
return re.test(obj);
}
else if (typeof(obj)=="object" && obj.className) {
return re.test(obj.className);
}
return false;
}
Kruse’s hasClass
Category: Uncategorized |
Tags: className, css, DOM, hasclass, icanhasclass, mattkruse, regex, selector, utilities, whitespace
Leave a Reply
You must be logged in to post a comment.