タイトルなしでレンダリングしたいjQueryUIダイアログボックスがあります。私はこれを機能させていますが、それは問題ではありません。
私が興味を持っているのは、jQuery:parent
セレクターがダイアログコンテンツdiv
の親を選択しないのに、parent()
関数が選択する理由です。実例は次のとおりです。
HTML:
<input id="example1" type="button" value="Use :parent selector">
<input id="example2" type="button" value="Use parent() function">
<!--
One of many dialogues on the page, but this one needs
the title removed.
-->
<div id="throbber" style="display:none">
<p>Doing work...be patient....</p>
<img src="http://i.stack.imgur.com/GUw9u.gif"/>
</div>
脚本:
$("#example1").bind("click", function() {
$("#throbber").dialog("destroy"); // for jsfiddle example
$("#throbber").dialog({
resizable: false,
modal: false,
width: 150
});
$("#throbber:parent .ui-dialog-titlebar").hide();
});
$("#example2").bind("click", function() {
$("#throbber").dialog("destroy"); // for jsfiddle example
$("#throbber").dialog({
resizable: false,
modal: false,
width: 150
});
$("#throbber").parent().find(".ui-dialog-titlebar").hide();
});
jsFiddleの上記のコードは次のとおりです。
Chromeでは、ダイアログをレンダリングした後にブレークポイントを設定すると$("#throbber:parent")
、予想どおり、それ自体が選択されます。
私がそれを選択しようとすると、それは選択し:parent
ません、それはただそれ自身を再び選択します:
を使用する場合$("#throbber").parent()
、今回はその親を選択します。
ここで何が起こっているのですか、なぜの親をまだ:parent
選択しないのですか?#throbber
.parent()