我正在试图找出一种方法来选择以下JSFiddle中的iFrame,其中包含'Test'。我试图这样做的方式如下,但它似乎没有工作。我无法使用class / id选择任何内容,因为div是在我的网站中动态生成的。
$('.big-box').each(function(index)
{
if ($(this).find("div").find("iframe").contents().find("body").contents().length > 0)
{
console.log("Trigger");
};
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<div class="big-box">
<iframe>
Other
</iframe>
<div>
<iframe>
<body>
Test
</body>
</iframe>
</div>
</div>