jQuery stay focused!

This is really just something for all you new jQuery learners, if you want to keep the cursor inside of a text box, even if you click elsewhere on the page, you can do this:

//Initial focus on #inputfieldid
$(”#inputfieldid”).focus();

//When you click anywhere it focuses back on #inputfieldid
$(this).click(function(){
$(”#inputfieldid”).focus();
});

Share:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • Reddit
  • Slashdot
  • StumbleUpon

Leave a Reply