當在jquery中使用each()函數爲一組(比如說3個單選按鈕)時,如何檢索第三個按鈕,發生? 基本上,我如何從each()函數中選擇要使用的元素?如何從jquery中的每個函數獲取單選按鈕索引號
這裏是我的編碼:
HTML:
<form id="orderDefinition" name="orderDefinition">
<fieldset>
<input type="radio" name="radioGroup" /><label for="">radio 1</label>
<input type="radio" name="radioGroup" /><label for="">radio 2</label>
<input type="radio" name="radioGroup" /><label for="">radio 3</label>
</fieldset>
</form>
的jQuery:
var radioBtnCollection = $("#orderDefinition input:radio");
$(radioBtnCollection).each(function(){
// From here, I don't know how to get the element
});
在此先感謝。
這是值得注意的是,* radioBtnCollection *已經是一個jQuery對象,並且不需要再傳遞給jQuery。你可以使用'radioBtnCollection.each(function(){...});' – 2010-09-10 10:48:03