Home  >  Article  >  Web Front-end  >  jQuery adds the implementation code of click event to the body of iframe_jquery

jQuery adds the implementation code of click event to the body of iframe_jquery

WBOY
WBOYOriginal
2016-05-16 18:08:221391browse

html结构如下:

复制代码 代码如下:



为body添加click事件


<script> <br>function show_body_click(){ <br>alert('you are click the body'); <br>} <br>jQuery(document).ready(function(){ <br>//jQuery("ifr_id").contents().find("body").attr("onclick", "show_body_click()"); <br>//alert(jQuery("#ifr_id").contents().find('body').attr("onclick",'xxxx()'));//不能实现 <br>//var ifr = jQuery("ifr_id") <br>}); <br>jQuery(document, '#ifr_id').ready(function(){ <br>jQuery("#ifr_id").contents().find("body").attr("onclick", "parent.show_body_click()"); <br>//jQuery("#ifr_id").contents().find("body").live("click", "parent.show_body_click()");//ff没有效果 <br>//jQuery("#ifr_id").contents().find("body").click(parent.show_body_click()); //ff没有效果 <br>}); <br><br></script>







Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn