2013-03-17 32 views
0

我有這個jQuery腳本,用於檢查輸入字段是否發生了更改,如果有,它會將一個類添加到圖標中(然後更改顏色以讓用戶知道他們已經填寫了該字段)。Jquery檢查輸入字段是否已在每個鍵上更改

$('.input-icon input').change(function() { 
    $(this).next(".icon").addClass('complete'); 
}); 

它的工作原理,但只有當有問題的領域後,文本已被輸入到它被取消。我需要的是每按一次鍵就運行一次並相應更新。

謝謝你們。

回答

1

http://api.jquery.com/keyup/

$('.input-icon input').on('keyup',function() { 
    // check if input has something in it 
    $(this).next(".icon").addClass('complete'); 
}); 

DEMO

+0

完美。非常感謝。 – GuerillaRadio 2013-03-17 23:16:54

相關問題