[英]How selecting parent element from iframe.contents()?
当我单击iframe时,我想调用一个函数,而我的解决方案在jQuery上也能很好地工作,但是当函数被触发时,我需要回到包含iframe的元素。
$('#window-3 iframe').load(function () {
$(this).contents().find("body").click(function () {
// Here I need to select the iframe again
});
});
在这种情况下,您需要$(this).parent()
。 如果要选择具有特定类的父母,则可以使用$(this).parents('#window-3')
例如。
您可能还需要清除任何潜在的范围界定问题:
$('#window-3 iframe').load(function () {
var _me = $(this);
_me.contents().find("body").click(function () {
var _parent = _me.parent()
// Here I need to select the iframe again
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.