Entries for month: January 2010

Defaulting cursor to the first input box with jQuery

Here's a short and simple  javascript using Jquery to put the cursor in the first text box on a web page.  I added this to one of our sites to make sure the cursor starts in the different forms / search boxes on all the pages of our site.

<script type="text/javascript"><!--
$document.ready(function()){
$("input[type='text']:first").select();
};}
// -->
</script>

It's using Jquery to find the FIRST :  INPUT tag with a TYPE="TEXT" on the page.  Then it selects it to move the cursor.