I want to change a menu button in a page when it selected. No problems: I wrote (just using an example):
In CSS:
.idleColor{background:#0f0; ... }
.redColor {background:#f00;}
In HTML:
<input id='m3' type=button class=idleColor>
....
<script> /* at page end */
$(document).foundation();
....
var activeButton = $("#m"+menuId); //assuming menuID=3
activeButton.addClass("redColor");
</script>
This should replace the button background color from the idle color to the active one...simple, but not working.
Two strange things: with Firebug I see that the class is added, both in 'className' and in 'classList', but the new color does not come up (and I do not thing I should reflow the button).
The other odd thing is that if I use $("#myID").classList.add("redColor") I get an error saying: myID.classList is undefined (?)
Environment:
Foundation Site 6
JQuery: jquery-2.2.4