(function ($) {
var placeholderfriend = {
Focus:function (s) {
s = $ (s). Hide (). Prev (). Show (). focus ();
var idvalue = s.attr ("id");
if (idvalue) {
S.ATTR ("id", Idvalue.replace ("Placeholderfriend", ""));
}
var clsvalue = s.attr ("class");
if (Clsvalue) {
S.attr ("Class", Clsvalue.replace ("Placeholderfriend", ""));
}
}
}
Determine if placeholder is supported
function Isplaceholer () {
var input = document.createelement (' input ');
Return "placeholder" in input;
}
Unsupported Code
if (!isplaceholer ()) {
$ (function () {
var form = $ (this);
var elements = form.find ("input[type= ' text '][placeholder]");
Elements.each (function () {
var s = $ (this);
var pValue = s.attr ("placeholder");
var svalue = S.val ();
if (PValue) {
if (svalue = = ") {
S.val (PValue). CSS (' color ', ' #E0E0E0 ');
}
}
});
Elements.focus (function () {
var s = $ (this);
var pValue = s.attr ("placeholder");
var svalue = S.val ();
if (svalue && pValue) {
if (svalue = = PValue) {
S.val ('). CSS (' color ', ' #E0E0E0 ');
}
}
});
Elements.blur (function () {
var s = $ (this);
var pValue = s.attr ("placeholder");
var svalue = S.val ();
if (!svalue) {
S.val (PValue);
}
});
var element_em = form.find ("input[type= ' email '][placeholder]");
Element_em.each (function () {
var s = $ (this);
var pValue = s.attr ("placeholder");
var svalue = S.val ();
if (PValue) {
if (svalue = = ") {
S.val (PValue). CSS (' color ', ' #E0E0E0 ');
}
}
});
Element_em.focus (function () {
var s = $ (this);
var pValue = s.attr ("placeholder");
var svalue = S.val ();
if (svalue && pValue) {
if (svalue = = PValue) {
S.val ('). CSS (' color ', ' #E0E0E0 ');
}
}
});
Element_em.blur (function () {
var s = $ (this);
var pValue = s.attr ("placeholder");
var svalue = S.val ();
if (!svalue) {
S.val (PValue);
}
});
var elementspass = form.find ("input[type= ' password '][placeholder]");
Elementspass.each (function (i) {
var s = $ (this);
var pValue = s.attr ("placeholder");
var svalue = S.val ();
S.val (svalue). CSS (' color ', ' #e0e0e0 ');
if (PValue) {
if (svalue = = ") {
var html = this.outerhtml | | "";
html = html.replace (/\s*type= ([' "])? Password\1/gi," Type=text placeholderfriend "). Replace (/\s* (?: value|on[a-z]+| Name) (= (['])? \s*\1)?/gi, ""). Replace (/\s*placeholderfriend/, "Placeholderfriend value= '" + pValue + "'" + "onfocus=" pl Aceholderfriendfocus (this); ' ");
var idvalue = s.attr ("id");
if (idvalue) {
S.ATTR ("id", Idvalue + "placeholderfriend");
}
var clsvalue = s.attr ("class");
if (Clsvalue) {
S.attr ("Class", Clsvalue + "placeholderfriend");
}
S.hide ();
S.after (HTML);
}
}
});
Elementspass.blur (function () {
var s = $ (this);
var svalue = S.val ();
if (svalue = = ") {
var idvalue = s.attr ("id");
if (idvalue) {
S.ATTR ("id", Idvalue + "placeholderfriend");
}
var clsvalue = s.attr ("class");
if (Clsvalue) {
S.attr ("Class", Clsvalue + "placeholderfriend");
}
S.hide (). Next (). Show ();
}
});
});
}
Window.placeholderfriendfocus = Placeholderfriend.focus;
}) (JQuery);
Ie6\7\8 placeholder effect, support text box and Password box