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
Sure:
Think about your user interface before you do this. I assume (though none of the answers has said so) that you'll be doing this when the document loads using jQuery's
ready()
function. If a user has already focussed on a different element before the document has loaded (which is perfectly possible) then it's extremely irritating for them to have the focus stolen away.You could check for this by adding
onfocus
attributes in each of your<input>
elements to record whether the user has already focussed on a form field and then not stealing the focus if they have:Sorry for bumping an old question. I found this via google.
Its also worth noting that its possible to use more than one selector, thus you can target any form element, and not just one specific type.
eg.
This will focus the first input or textarea it finds, and of course you can add other selectors into the mix as well. Hnady if you can't be certain of a specific element type being first, or if you want something a bit general/reusable.
This is what I prefer to use:
place after input
The Simple and easiest way to achieve this