Placeholder Properties, Firefox, Google Chrome and other expressions of support, only ie there is vainly disobey sense Ah!
HTML5 has made many enhancements to the Web Form, such as input type, Form validation, and so on.
Placeholder is another property added by HTML5, and when input or textarea is set, the content of the value is displayed as a gray hint in the text box, and the hint text disappears when the text box gets the focus. Previously, this effect was controlled by JavaScript to achieve
For example:<input ID="T1" type="Text"placeholder="Please enter text" />
Introduce a super strong let IE support placeholder property plug-in, but also compatible with other browsers do not support placeholder, the code is as follows:
$ (document ). Ready (function () {var doc=document, inputs=doc.getelementsbytagname (' input '), supportplaceholder= ' placeholder ' In doc.createelement (' input '), placeholder=function (input) {var text=input.getattribute (' placeholder '), DE Faultvalue=input.defaultvalue; if (defaultvalue== ") {Input.value=text} input.onfocus=function () {if (Input.value===text) { This.value= '}; Input.onblur=function () {if (input.value=== ') {This.value=text}}}; if (!supportplaceholder) {for (Var i=0,len=inputs.length;i<len;i++) {var input=inputs[i], Text=inpu T.getattribute (' placeholder '); if (input.type=== ' text ' &&text) {placeholder (input)}}});
directly copy the code down, save as a JS file reference can, no longer do any processing, super convenient!
HTML5 's Placeholder property (ie compatible)