Home > Web Front-end > JS Tutorial > body text

jQuery implements the code to display or hide the prompt text value in the form input as the mouse focus moves in and out_jquery

WBOY
Release: 2016-05-16 18:31:41
Original
1236 people have browsed it
Copy code The code is as follows:




<script> <br>$(function(){ <br>//Control the text color in the input box<br>$("input:not(:last)").css("color","#999"); <br>} ); <br>//Mouse focus moves into the username box and the text disappears<br>$("input:first").click(function () { <br>var check1 = $(this).val(); <br>if (check1 == this.defaultValue) { <br>$(this).val(""); <br>} <br>}); <br>//The mouse focus of the user name box moves out, and the text Display<br>$("input:first").blur(function () { <br>$(this).val(this.defaultValue); <br>}); <br>//Mouse focus of password box Enter, the text disappears<br>$("input:eq(1)").click(function () { <br>var check2 = $(this).val(); <br>if (check2 == this. defaultValue) { <br>$(this).val(""); <br>} <br>//Mouse focus of the password box is moved out, and the text is displayed<br>$("input:eq(1)").blur (function () { <br>$(this).val(this.defaultValue); <br>}); <br>}) <br></script>
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!