当我单击iframe时,我想调用一个函数,我的解决方案在jQuery中运行得很好,但是当函数被触发时,我需要回到包含iframe的元素。
$('#window-3 iframe').load(function () {
$(this).contents().find("body").click(function () {
// Here I need to select the iframe again
});
});发布于 2014-03-03 15:16:05
在这种情况下,您需要$(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
});
});https://stackoverflow.com/questions/22150373
复制相似问题