April 10, 2012
Jquery Toggle Slider & Toggle Text
Question by Jay J.
I’m trying to slide down a div after the “Show” link is clicked and change that text to “Hide” but it doesn’t seem to work so well.
<div id="mobilemenu"><a id="#menutoggle" href="#">Show</a></div>
<div id="slider">Content to slide in under #mobilemenu</div>
I tried solving with some of the other StackOverflow answers, but I couldn’t get it to work so not sure what I’m doing wrong.
Answer by Starx
Update your anchor. Remove the #
from the id and attach an event handler.
$("#menutoggle").click(function() {
$("#slider").toggle();
});