简体   繁体   English

页面加载后如何使文本输入框光标自动闪烁?

[英]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.

相关问题 更改选项卡后如何在输入文本框中闪烁光标 - How to blink cursor in input text box after changed tab 当页面使用JavaScript / jQuery加载时,如何获取选择框的第一个选项以自动显示在div中? - How do I get the first option of a select box to display in a div automatically when the page loads with JavaScript/jQuery? 在Javascript中,如何在当前文本框已满时自动将光标移动到下一个文本框? - In Javascript, how do I automatically move the cursor to the next text box when the current one is full? 如何在页面加载时自动切换到此元素 - How do I automatically tab to this element when the page loads 页面加载时如何关注输入框? - How to focus on input box when page loads? 如何将与img的链接链接到文本输入/提交框中,然后将输入的内容传递到另一个页面? - How do I make a link with img into a text input/submit box that then passes whatever was entered to another page? 当变量随Angular更改时如何闪烁 - How do I make something blink when a variable changes with Angular 如何在页面加载时自动点击Chrome扩展程序? - How can I make a Chrome extension automatically click a button when a page loads? 页面加载时,Qualtrics Javascript聚焦/选择/将光标置于文本框上 - Qualtrics Javascript focus / select / place cursor on text box when page loads 在 React JS 中加载页面时如何自动调用 function?(2020 年) - How do I call a function automatically when page loads up in React JS ?(in 2020)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM