Commentaire: Cet article présente principalement l'attribut d'espaceur d'accès HTML 5 pour servir parfaitement comme IE. Les amis qui en ont besoin peuvent y faire référence
N'oubliez pas de référencer la bibliothèque de classe JQuery$ (document) .ready (function () {
if ($ .browser.msie)
$ ("entrée: texte, entrée: mot de passe"). chaque (fonction () {
var $ placeholder = $ (this) .attr ("placeholder");
var $ width = $ (this) .css ("width");
var $ id = $ (this) .attr ("id");
var $ height = parseInt ($ (this) .css ("height")) + 6 + "px";
var $ fonTSize = $ (this) .css ("font-size");
var $ fontweight = $ (this) .css ("Font-Weight");
var $ lineheight = $ height;
if ($ (this) .css ("line-height")! = "normal") {
$ lineheight = parseInt ($ (this) .css ("line-height")) + 6 + "px";
}
if ($ placeholder! = Undefined) {
$(this).after("<span class=/"placeholder ph_" + $id + "/" style=/"width:" + $width + ";line-height:" + $lineHeight + ";height:" + $height + ";font-weight:" + $fontWeight + ";margin-left:-" + $width + ";font-size:" + $fontSize + "/">" + $ placeholder + "</span>");
}
$ (this) .bind ("keyup", function () {
if ($ (this) .val () == "") {
$ (this) .parent (). trouver (". Ph_" + $ id) .css ("affichage", "en ligne");
}
autre {
$ (this) .parent (). trouver (". Ph_" + $ id) .css ("affiche", "aucun");
}
});
});
$ (". Planholder"). Live ("Click", fonction () {
$ (this) .prev (). focus ();
});
});
Appel de page
<input type = "text" placeholder = "J'invite le contenu est normal" />
<input type = "text" placeholder = "J'invite la largeur et la hauteur du contenu" />
<input type = "text" placeholder = "J'invite du contenu J'ai d'autres styles" />
<input type = "text" placeholder = "vous pouvez essayer d'autres" />
style
<style type = "text / css">
.PlaceHolder {affichage: bloc en ligne; couleur: gris; adigne verticale: haut; débordement: caché;}
</ style>