1
我有這樣的jQuery選擇標籤第一選擇
$('.accordion label').live('click',function() {
alert("hello clicky clicky");
}
,但如果我這樣做
$('.accordion label:first').live('click',function() {
alert("hello clicky clicky");
}
它的目標是第一手風琴的標籤,而不是每一個手風琴的第一個標籤
會有人請幫忙
編輯
HTML
<fieldset class="horizontal accordion">
<label class="categorylabel"><div class="accordion_open"></div>Editor Information</label>
<ul>
<li>
<label for="editor" id="editorL"><div class="accordion_open"></div>Editor Name</label>
<input id="editor" name="editor" class="force_clean" value="" type="text">
</li>
</ul>
</fieldset>
針對每個標籤 – mcgrailm 2010-07-06 15:40:13
@mcgrailm - 我從您的HTML中看到,您有額外的嵌套'標籤'元素。這是一個簡單的修復。只需將'>'放置在選擇器中,使其僅針對直接的孩子。另外,你可以簡單地使用'.categorylabel'類。我會用兩個更新我的答案。 – user113716 2010-07-06 15:45:07
真棒謝謝 – mcgrailm 2010-07-06 15:50:04