/ Published in: JavaScript
This Matt Kruse's hasClass function.
Expand |
Embed | Plain Text
/* ** 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; }
You need to login to post a comment.
