0

uu我正在尝试检测 iframe 内的点击事件。我已经在 SO 上找到了一些(不工作的)解决方案,但我无法修复它们并让它们在我的代码上工作。

如何检测 iframe 内的点击事件的目标?

由于 PrettyPhoto 只是由

$("a[rel^='prettyPhoto']").prettyPhoto();

我希望有一个类似于

$("a[rel^='prettyPhoto']").prettyPhoto(
     $('#myframe').bind('click', function(event) {
          alert("cliked");
     })
);

但这不起作用。任何想法?

4

2 回答 2

0

利用.on()

$('#myframe').on('click', function(event) {
       alert("cliked");
})
于 2013-03-04T09:58:41.963 回答
0

你可以把它放在外面,prettyphoto();如果你使用的是最新的 jquery,那么使用.on()处理程序:

$("a[rel^='prettyPhoto']").prettyPhoto();
$('#myframe').on('click', function(event) {
      alert("cliked");
});
于 2013-03-04T10:22:49.050 回答