This article illustrates the method of jquery simple implementation of gray hint text in the input text box. Share to everyone for your reference, specific as follows:
$ (function () {
$ (". Graytips"). each (function () {//Traverse each text box
var objtextbox=$ (this);
var Oldtext=$.trim (Objtextbox.val ());
OBJTEXTBOX.CSS ("Color", "#888");
Objtextbox.focus (function () {
if (Objtextbox.val ()!=oldtext) {
objtextbox.css ("Color", "#000");
}
else{
Objtextbox.val (""). CSS ("Color", "#888");
Objtextbox.blur (function () {
if (objtextbox.val () = "") {
objtextbox.val (oldtext). CSS ("Color", "#888");
});
Objtextbox.keydown (function () {
objtextbox.css ("Color", "#000");
});
});
Description: Need to introduce jquery.js file input and textbox are valid
$ (function () {
$ (". Graytip"). each (function () {
var $input =$ (this);
$input. CSS ("Color", "#888");
var Oldtext=$.trim ($input. Val ());
$input. focus (function () {
var Newtext=$.trim ($input. Val ());
if (newtext==oldtext) {
$input. val ("");
}
$input. CSS ("Color", "#000");
$input. blur (function () {
var Newtext=$.trim ($input. Val ());
if (newtext== "") {
$input. val (oldtext);
$input. CSS ("Color", "#888");
}
})
;
I hope this article will help you with the jquery program design.