Home >Web Front-end >JS Tutorial >Clear text box content when a text box becomes focus_javascript technique

Clear text box content when a text box becomes focus_javascript technique

WBOY
WBOYOriginal
2016-05-16 16:50:531312browse
Copy code The code is as follows:





Clear the text box content when it becomes focus
<script> <br>window .onload = initAll; <br><br>function initAll(){ <br>var clearText = document.getElementsByTagName("input"); <br>for (var i=0; i<clearText.length; i ){ <BR>clearText[i].onfocus = function ( ){ <BR>this.value = ""; <BR>} <BR>} <BR>} <BR></script>



Text box one:

Text box two:

Text box three:

< ;/html>
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