【发布时间】:2013-06-04 22:59:46
【问题描述】:
如果用户单击图像,我希望它同时触发对指定 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>
【问题讨论】:
-
你最好自己尝试一下,如果发现问题,把代码一起解决:)
-
好的,我刚刚用我目前得到的代码更新了我的原始问题。
标签: jquery