Javascript jQuery选择主文档和主文档中的所有iframes文档(选择一个)

Javascript jQuery选择主文档和主文档中的所有iframes文档(选择一个),javascript,iframe,jquery,Javascript,Iframe,Jquery,我试图在主文档+页面中的所有iframe上触发on mousemove事件。我可以通过两种选择来实现这一点: $(document).on( "mousemove", handler ); $("iframe").contents().on( "mousemove", handler ); 我可以用一个选项来做这个吗 我尝试了这一点,但仅适用于主文档: $(document,$("iframe").contents()).on( "mousemove", handler ); 谢谢关于$(

我试图在主文档+页面中的所有iframe上触发on mousemove事件。我可以通过两种选择来实现这一点:

$(document).on( "mousemove", handler );

$("iframe").contents().on( "mousemove", handler );
我可以用一个选项来做这个吗

我尝试了这一点,但仅适用于主文档:

$(document,$("iframe").contents()).on( "mousemove", handler );

谢谢

关于
$(document).contents()。关于(“mousemove”,handler)
@Murali我刚刚试过,只对主文档有效。@Doua,我不确定你能不能做到。IIRC jQuery对象存储集合中所有元素所属的文档,因此我认为不能在同一jQuery对象中混合来自不同文档的元素。