I have this:
我有这个:
$(".slideDownArrow").click(function(){
currentBlockIndex++;
$('.secondLevel li').eq(currentBlockIndex).trigger('click');
});
and when I click on the slideDownArrow
it works for me and many other people, but not for everyone - my client has to click twice to trigger the secondLevel li
click event. What could be the cause of it and how could I fix this?
当我点击slideDownArrow时,它适用于我和许多其他人,但不适合所有人 - 我的客户端必须单击两次才能触发secondLevel li click事件。可能是什么原因,我怎么能解决这个问题?
The secondLevel li
click function:
第二级点击功能:
$('.secondLevel li, .exteriorBox li').bind('click', function(){
var el = $(this),
elIndex = el.index();
$('html, body').animate({
scrollTop: hArray[elIndex]
}, 1000);
});
1 个解决方案
#1
Go straight to the HtmlElement click method instead:
直接转到HtmlElement单击方法:
$('.secondLevel li')[currentBlockIndex].click();
Rather than use get()
, []
returns the HTML element. click
is the native click event generator.
而不是使用get(),[]返回HTML元素。 click是本机点击事件生成器。
As the event is in response to a user click, you can ignore any comments about security reason. I have tried this on all browsers and no problems.
由于事件是对用户单击的响应,因此您可以忽略有关安全原因的任何注释。我已经在所有浏览器上尝试过这个并没有问题。
#1
Go straight to the HtmlElement click method instead:
直接转到HtmlElement单击方法:
$('.secondLevel li')[currentBlockIndex].click();
Rather than use get()
, []
returns the HTML element. click
is the native click event generator.
而不是使用get(),[]返回HTML元素。 click是本机点击事件生成器。
As the event is in response to a user click, you can ignore any comments about security reason. I have tried this on all browsers and no problems.
由于事件是对用户单击的响应,因此您可以忽略有关安全原因的任何注释。我已经在所有浏览器上尝试过这个并没有问题。