jquery :contains セレクターを使用しようとしている子ウィンドウがありますが、機能しません。
var child = window.open("index.html", null);
child.document.close();//I saw somewhere this was necessary...
$(child.document).ready(function() {
setTimeout( function() { // necessary to wait a few seconds
console.log($('.navigation .option:nth-child(4)', child.document).length);
console.log($('.navigation .option:contains("Item4")', child.document).length);
}, 5000);
});
:nth-child は正しく「Item4」を返します。2番目は見つかりません。HTML は次のとおりです。
<div class="navigation">
<div class="option">Item1</div>
<div class="option">Item2</div>
<div class="option">Item3</div>
<div class="option">Item4</div>
</div>
通常のウィンドウでは、:contains セレクターが機能します - 問題ありません。子ウィンドウで jquery が :contains を処理できないようです。これは本当ですか?