In IE 8 and earlier browsers, The placeholder attribute is not supported. ie8placeholder

Source: Internet
Author: User

In IE 8 and earlier browsers, The placeholder attribute is not supported. ie8placeholder

The following code does not support the placeholder attribute in IE8 and earlier browsers.

Principle: Write the value of placeholder into the control as the content, and add the control event for simulation.

; (Function () {if (! ('Holder' in document. createElement ('input') {// match all input and textarea except type = password $ ('input [placeholder] [type! = Password], textarea [placeholder] '). each (function () {var self = $ (this), text = self. attr ('placeholder'); // if the content is empty, write if (self. val () = "") {self. val (text ). addClass ('holder');} // controls are activated to clear the placeholder self. focus (function () {if (self. val () = text) {self. val (""). removeClass ('placeholder ');} // The control loses focus and clears placeholder }). blur (function () {if (self. val () = "") {self. val (text ). addClass ('placeholder ');}});});}})();

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.