Link to home
Start Free TrialLog in
Avatar of dkim18
dkim18

asked on

setting focus end of line

Hi Experts,

I have the following code for setting focus to the first input element.
<script>
			$(document).ready(function() {
    			var first_input = $('input[type=text]:visible:enabled:first, textarea:visible:enabled:first')[0];
    			
    			if(first_input != undefined){ 
    				
    				first_input.focus();
    				
    			}
			});
</script>

Open in new window


I put that in inside of head tag, so it can handle many different forms.
Now, I am trying to set focus end of line if there is already user input. Since there is no id for  most text fields and text areas, how do I handle that?
Isn't .get() function doesn't work either.

thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of chaau
chaau
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dkim18
dkim18

ASKER

It works. Thanks!