问题
They wanted to have a simple toggle open close accordion like interaction. Not trying to reinvent the wheel but just trying to learn jquery/javascript. Everything is going smoothly until I tested on firefox. On click my accordion just disappears... is this my fault? jquery's fault? codepen's fault?
Codepen interaction
回答1:
Change js code like this
$(".x-button").click(function () {
$(".inner-info-container").slideToggle("slow");
$(this).toggleClass("x-button p-button");
return false;//insert this line
});
回答2:
You need to add return false
after the $(this).toggleClass("x-button p-button");
return false
just means it doesn't try to go to the href, it stops the normal link behavior.
来源:https://stackoverflow.com/questions/17847585/firefox-makes-simple-jquery-slidetoggle-disappear