[Javascript]
Var placeholder = function (arrObj ){
If (! ('Holder' in document. createElement ('input ')))
{
Var bind = function (name, val ){
Name. focus (function (){
Var o = $ (this );
If (o. val () = val)
{
O. val ("");
O.css ({"color": "#000 "})
}
}). Blur (function (){
Var o = $ (this );
If (! O. val () | o. val () = val)
{
O. val (val );
O.css ({"color": "# c0c0c0 "})
}
}). Blur ();
};
If (arrObj ){
For (var I in arrObj)
{
Var txt = $ (arrObj [I] ["name"]);
Var textDefault = arrObj [I] ["val"] | "enter ";
Bind (txt, textDefault );
}
}
Else
{
$ ("Input [placeholder]"). each (function (){
Var o = $ (this)
Bind (o, o. attr ("placeholder "));
})
}
} Else
{
For (var I in arrObj)
{
Var txt = $ (arrObj [I] ["name"]);
Var textDefault = arrObj [I] ["val"] | "enter ";
Txt. attr ("placeholder", textDefault)
}
}
}
[Javascript]
// Usage method 1
Placeholder ();
// Method 2
/* Placeholder ([
{Name: "# name", val: "Enter the user name/Email Address "},
{Name: "# pwd", val: "enter your password "}
]) */
Author: chaiyining007