I want to change a class onclick. What I have at the moment:
<script>
function changeclass() {
var NAME = document.getElementById("myclass")
NAME.className="mynewclass"
}
</script>
But, ofcourse, its not working. Also, it should revert to previuos state onclick again.
My html:
<div id="showhide" class="meta-info" onclick="changeclass();">
So, whenever I press on #showhide myclass should change to mynewclass. Thanks for help in advance!
With jquery you could do to sth. like this, which will simply switch classes.
If you want to switch classes back and forth on each click, you can use toggleClass, like so: