[英]Why do I need to click twice to fire up this jQuery event?
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. 当我单击
slideDownArrow
它对我和其他很多人都有效,但对每个人都不适用-我的客户必须单击两次才能触发secondLevel li
click事件。 What could be the cause of it and how could I fix this? 可能是什么原因造成的,我该如何解决?
The secondLevel li
click function: secondLevel li
点击功能:
$('.secondLevel li, .exteriorBox li').bind('click', function(){
var el = $(this),
elIndex = el.index();
$('html, body').animate({
scrollTop: hArray[elIndex]
}, 1000);
});
Go straight to the HtmlElement click method instead: 直接转到HtmlElement click方法 :
$('.secondLevel li')[currentBlockIndex].click();
Rather than use get()
, []
returns the HTML element. 而不是使用
get()
, []
返回HTML元素。 click
is the native click event generator. 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.
我已经在所有浏览器上尝试过了,没有问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.