JS / JQUERY:on(滚动)干扰on(click)

时间:2018-05-25 16:21:39

标签: javascript jquery

所以,在我网站的脚本中,我有功能:

$(window).on('scroll', function(){
     // some code
});

$('.subnav_single_box').on('click', function(){
      $('#h1').animate({ right : '300%'}, 1000);  
     // some more code -shall refer to this block of code later
 });

问题是on(click)内的some_more_code有效,但#h1 - 代码有时无效。

如果我在点击.subnav_single_box之前没有滚动,那么一切都按照我想要的方式工作,但是如果我在点击之前滚动,那么“更多代码”可以工作,但不是#h1 - 代码。

我该如何解决这个问题?

0 个答案:

没有答案
相关问题