How do I make the text input box cursor blink automatically when the page loads?

半腔热情 提交于 2021-02-08 07:39:44

问题


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


回答1:


You have to set focus on the text box.

This can be done either by

JavaScript document.getElementById("fname").focus();

or

Jquery $( "#fname" ).focus();

or

HTML5 <input type="text" name="fname" autofocus />




回答2:


In HTML5, you can simply use the input autofocus attribute.

However, beware that this does not work in some versions of IE.



来源:https://stackoverflow.com/questions/20769235/how-do-i-make-the-text-input-box-cursor-blink-automatically-when-the-page-loads

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!