Any good for you ... ? $(document).ready(function(){ var hasFocus = $(':text:first').focus(); $(document).bind('click', function(event){ var ev = $(event.target); if(ev != hasFocus){ if (ev.is(':text')){ hasFocus = ev; } hasFocus.focus(); } }); });
On Jun 5, 2:30 am, paulj <[EMAIL PROTECTED]> wrote: > Hi, > > When a text box has the focus, I would like it to keep the focus even > when another element type (not another text box) is clicked. eg after > clicking this other element type, the user can press a key(s) and the > text box will accept this key input without the user having to click > back into the text box. > Hope this makes sense. > > Karl gave me some info. the other day and I was pretty sure I would be > able to fine-tune it for my app. but the best I could come up with > is : > > $(document).ready(function() > { > $(':text').blur(function(event) > { > if (!$(event.target).is(':text')) > { $(this).focus() } > }); > > }); > > Thanks for any help > Paul > > Here is the full code : > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/ > TR/html4/strict.dtd"> > <html> > > <head> > > <title></title> > <meta http-equiv="Content-Type" content="text/html; > charset=ISO-8859-1"> > > <style type="text/css"> > input { width : 700px ; } > > </style> > > <script type = "text/javascript" src="jquery.js"></script> > <script type = "text/javascript"> > > $(document).ready(function() > { > $(':text').blur(function(event) > { > if (!$(event.target).is(':text')) > { $(this).focus() } > }); > > }); > > </script> > > </head> > > <body> > > <ul> > <li>click here</li> > <li>or click here</li> > </ul> > > <br> <br> > > <form> > > <input type='text' class='test' value='these text boxes should retain > the focus when another element type is clicked'> <br><br> > <input type='text' value='these text boxes should retain the focus > when another element type is clicked'> <br><br> > <input type='text' value='these text boxes should retain the focus > when another element type is clicked' id='focusHere'> <br> > > </form> > > </body> > > </html>