I'm almost there, a little unsure of my code setup, I basically want to remove the class on click and add it to onclick again, then delete onclick and then add onclick. Etc! Here, what I have is almost there, but if there is a better way to do this, then please help! Thank.
document.getElementById('myButton').onclick = function() {
myButton.className = myButton.className.replace(/(?:^|\s)active(?!\S)/g, '') ? 'active': jbar.className.replace(/(?:^|\s)active(?!\S)/g, '') ;
}
Any help is much appreciated!
user1323595
source
share