Home >
Web Front-end >
JS Tutorial >
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
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
<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>
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