常用在走訪同樣class的物件,比如:
HTML:
<form> <input class="each_test" value="1" /> <input class="each_test" value="2" /> <input class="each_test" value="3" /> </form>
jQuery:
//執行出來的結果會是1 2 3,index的值為0 1 2 $('.each_test').each(function(index){ alert($(this).val()); });