How to move the cursor position into a input text box by clicking a label tag?
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();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With