jQuery click事件-需要两次单击才能触发 [英] Jquery click event - requires two clicks to fire

查看:189
本文介绍了jQuery click事件-需要两次单击才能触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能非常简单-但是我正在努力发现正在发生的事情.

This may be super simple - but I'm struggling to spot what's going on.

在JS小提琴上: http://jsfiddle.net/3hHAX/

有两个链接输出到打开视频模式".

There are two links output to 'Open video modal'.

正如链接文本所建议的那样,这两个链接应打开一个包含所包含的youtube视频的模型弹出窗口.

As the link text suggests these two links should open a model pop-up with the youtube video contained.

这是从以下位置使用prettyphoto库的: http ://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/

This is using the prettyphoto library from: http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/

由于某种原因,单击事件不会在首次单击时触发. 但仅次于秒.

For some reason the click event doesn't trigger on first click. But works on second.

(没有包含CSS,因此看起来不是很模态,但是至少出于演示的目的,您会在下面看到内容加载).

(Haven't included the CSS so doesn't look very modal, but you'll see the content load in below at least for purposes of demo).

谁能建议出什么问题了?

Can anyone suggest what's going wrong?

谢谢

史蒂夫

推荐答案

谢谢你们,

这两种回答都帮助我最终解决了这个问题.

Both responses helped me ultimately solve it.

已更新的JSFiddle中的最终解决方案:

End solution in the updated JSFiddle:

http://jsfiddle.net/3hHAX/6/

似乎prettyPhoto附加了它自己的click事件,只需要应用于这些dom元素即可.

Seems prettyPhoto attaches it's own on click event, and just needed applying to those dom elements.

谢谢, 史蒂夫

这篇关于jQuery click事件-需要两次单击才能触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆