jquery keystroke wait
How can I stop the loop until a 开发者_运维知识库key is pushed?
for (i=1;i<10;i++){
$('input').eq(i).css('border','1px solid red')
//Wait a keystroke ??????
}
You cannot "stop the loop". You can, however, wait for a "keypress" event.
var i = 1;
$('body').keypress(function() {
if (i >= 10) return true;
$('input').eq(i).css('border', '1px solid red');
i++;
});
That's just an example; there are other ways you might do it.
精彩评论