This is probably very simple, but could somebody tell me how to get the cursor blinking on a text box on page load?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- How to fix IE ClearType + jQuery opacity problem i
- void before promise syntax
You can use HTML5
autofocus
for this. You don't need jQuery or other JavaScript.Note this will not work on IE9 and lower.
Why is everybody using jQuery for something simple as this.
Set focus on the first text field:
This also does the first text field, but you can change the [0] to another index:
Or, you can use the ID:
HTML:
jQuery:
The line
$('#myTextBox').focus()
alone won't put the cursor in the text box, instead use: