Hi All,
How to move the cursor position into a input text box by clicking a label tag?
Much appreciated
Hi All,
How to move the cursor position into a input text box by clicking a label tag?
Much appreciated
Use the for
attribute. No need for any Javascript.
<label for="name">Name</label><input type="text" id="name" name="name" />
The browser will do the magic all by itself.
Don't know why Yi Jiang's answer wouldn't be working, but it's trivial in jQuery if you prefer to do it that way
$('#myLabel').click(function() {
$('#myTextBox').focus();
});