开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜