tags:

views:

24

answers:

1

Hi,

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 ??????
}
A: 

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.

Pointy