Home  >  Article  >  Web Front-end  >  How to set focus on HTML elements

How to set focus on HTML elements

高洛峰
高洛峰Original
2017-02-27 11:27:021753browse

HTML elements are mostly set using the focus method of js. There is an example below, you can refer to it

<body 
<form action="" method="post" name="form1" > 

<input type="text" id="id" /> 

</form> 

</body> 

<script> function myfocus() { document.getElementById(&#39;id&#39;).focus(); } </script>

For more related articles on how to set the focus of HTML elements, please pay attention to the PHP Chinese website !

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn