jQuery to trigger a click on an iFrame?

后端 未结 2 1658
不知归路
不知归路 2020-12-03 05:38

If a user clicks on an image I want that to simultaneously trigger a click on a specified iFrame as well. Is that possible? The image and iFrame are located on the same page

2条回答
  •  渐次进展
    2020-12-03 06:17

    I think you needed something like this:-

    $("#image").click(function(){
         var $iframe = $("#iframe").contents();
         $("body", $iframe).trigger("click");
    });
    

提交回复
热议问题