Firefox makes simple jquery slidetoggle() disappear

萝らか妹 提交于 2019-12-13 05:16:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!