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
Release: 2016-05-16 16:50:53
Original
1315 people have browsed it
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>
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template