开发者

jquery show/hide prevents site from opening in safari

Not very experienced here. but need to complete my website. My issue is that jquery seems to be preventing my site from opening first time in safari. the show and hide div function seems to be the problem any help would be much appreciated. http://www.designactivists.com/sem_4_2011/barebones/ is the link. the code looks like this. when is removed site opens perfectly.

<script language="javascript" src="jquery-1.5.2.min.js"></script>
<script language="javascript">
 $(document).ready(function() {
      $('#toggleButton').click(function() {
           if ($('#na开发者_如何学运维vbar').is(":hidden"))
           {
                $('#navbar').slideDown("slow");
           } else {
                $('#navbar').slideUp("slow");
           }
           return false;
      });
 });
 </script>


If IS keyword is the problem that you could achieve the same with following code:

$('#toggleButton').click(function(e) {
   e.stopPropagation();
   $('#navbar').slideToggle('slow');
});

FYI: Also remove the href="#" from the toggleButton. Instead use href="javascript:void(0);". This shall not take the user to top upon clicking the link.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜