道歉,如果這是一個愚蠢的問題,但它很難找到使用搜索引擎,但'>'作爲選擇器使用時的意思是什麼?當用作JQuery選擇器時,'>'是什麼意思?
E.g.
$('div.form-input > label')....
道歉,如果這是一個愚蠢的問題,但它很難找到使用搜索引擎,但'>'作爲選擇器使用時的意思是什麼?當用作JQuery選擇器時,'>'是什麼意思?
E.g.
$('div.form-input > label')....
它的父>子 - 選擇第二個選擇匹配的是第一選擇匹配的元素的兒童的所有元素。例如:
div.myclass > p.yourclass
將選擇您的類的所有p在myclass的div內。
一樣CSS,直接一個div內的標籤與form-input
$('div.form-input label') // label can be anywhere inside the div
$('div.form-input > label') // label must be directly inside the div (at top level)
爲58k代表答案它應該比「直接在裏面」 – Christoph
這是相同的CSS選擇器類,選擇直接孩子。
div.form-input > label
選擇將匹配直接label
後裔的div.form-input
它選擇一個div的孩子帶班「的形式輸入」這是一個標籤。您可以在這裏閱讀更多關於兒童選擇器http://api.jquery.com/child-selector/
這是child
選擇器。查看更多here。
jQuery('parent > child')
說明:選擇由「parent」指定的元素的「child」指定的所有直接子元素。
子選擇器:http://api.jquery.com/child-selector/ – Blazemonger
就像一個註釋,這個語法也適用於CSS。很多jQuery選擇器都基於CSS選擇器。 – roflmao