爲什麼會出現這種失敗...jQuery的:如何找到元素* *沒有某一類
$('div.contactAperson input').not('input.hadFocus').focus(function() {
$(this).attr('value', '');
});
...它的意思嗅出輸入的有沒有得到了類.hadFocus然後當其中一個子集接收到焦點時,它應該將值變爲null。
現在,輸入值總是變爲zapped - 測試.not('input.hadFocus')無法停止執行。
順便說一句,上面的代碼前面的是下面的代碼,這是工作的罰款:
$('div.contactAperson input').focus(function() {
$(this).addClass('hadFocus');
});
感謝任何聰明 - 歡呼聲,-Alan
重複的:我怎麼能不選擇在jQuery的一個給定類的所有元素?(http://stackoverflow.com/questions/2448051) – hippietrail 2012-12-02 02:46:04