小编use*_*693的帖子

jQuery触发iFrame上的点击?

如果用户点击我想要的图像同时触发指定iFrame上的点击.那可能吗?图像和iFrame位于同一页面上.如果是这样,你能告诉我可以使用的代码吗?

这是我到目前为止所拥有的:

<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
</head>
<body>
<img id="image" src="https://www.google.com/images/srpr/logo4w.png">

<iframe id="iframe" src="http://www.test.com" height= "100" width="160"></iframe>

<script>
jQuery("input.image").click(function(){
   $("#iframe").click()
});
</script> 

</body>
</html>
Run Code Online (Sandbox Code Playgroud)

jquery

10
推荐指数
1
解决办法
4万
查看次数

标签 统计

jquery ×1