Created
June 3, 2011 00:44
-
-
Save cduruk/1005646 to your computer and use it in GitHub Desktop.
Classer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.prototype.hasClass = function(className) { | |
return this.className.indexOf(className) !== -1; | |
} | |
Object.prototype.addClass = function(className) { | |
if this.hasClass(className) { | |
return false; | |
} | |
this.className = this.className += ' ' + className; | |
return true; | |
} | |
Object.prototype.removeClass = function(className) { | |
if this.hasClass(className) { | |
return false; | |
} | |
this.className = this.className.replace(className, ''); | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment