[英]How do I make the text input box cursor blink automatically when the page loads?
I want the cursor/line thing in the text box to automatically start blinking when the page loads. 我希望文本框中的光标/行内容在页面加载时自动开始闪烁。 I've tried 我试过了
contentEditable="true"
but that's not working 但这不起作用
You have to set focus on the text box. 您必须将焦点设置在文本框中。
This can be done either by 这可以通过以下方式完成
JavaScript document.getElementById("fname").focus();
JavaScript document.getElementById("fname").focus();
or 要么
Jquery $( "#fname" ).focus();
jQuery $( "#fname" ).focus();
or 要么
HTML5 <input type="text" name="fname" autofocus />
HTML5 <input type="text" name="fname" autofocus />
In HTML5, you can simply use the input autofocus attribute. 在HTML5中,您可以简单地使用输入自动对焦属性。
However, beware that this does not work in some versions of IE. 但是,请注意,这在某些版本的IE中不起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.