'htmlelement' Is Undefined In Ie8, An Alternative?
Hey all I have methods like this: // Has Class HTMLElement.prototype.hasClass = function (searchClass) {     return this.className.match(new RegExp('(\\s|^)' + searchClass + '(\\s|
Solution 1:
You can't add methods to HTMLElement.prototype in older versions of IE if I remember correctly. A simple workaround would be:
var hasClass = function (el, searchClass) {
    return el.className.test(newRegExp('(\\s|^)' + searchClass + '(\\s|$)'));
};
And used like:
alert(    hasClass(   document.getElementById('div1'), 'classToCheck'   )    )
DEMO
You can always add this to the Object.prototype object but it's frowned on
Post a Comment for "'htmlelement' Is Undefined In Ie8, An Alternative?"