HTML5 placeholder in ie10 below pseudo hint

Source: Internet
Author: User

Everyone is aware of HTML5 in Ie10 above the version only support, recently with the bootstrap front-end development framework to make a website, want to IE10 below can also hint, so you have to use JS camouflage under.

First determine if the browser supports placeholder

if (! (' Placeholder ' in document.createelement (' input '))

Then append text, which would have wanted to change the Val value directly, to get the mouse to clear, but if you need to verify that he is required to fill in the wrong. So the text is still appended.

$ ("input"). Not ("input[type= ' password ')". each (//Exclude Input binding event Password box
function () {
if ($ (this). val () = = "" && $ (this). attr ("placeholder")! = undefined) {
$ (this). After (' <input class= ' + $ (this). attr ("class") + ' "type=" text "Value= ' + $ (this). attr (" placeholder ") + ' Autoc omplete= "Off"/> ');
$ (this). Val ($ (this). attr ("placeholder"));
$ (this). Hide (); $ (this). Next (). Show ();
$ (this). Next (). focus (function () {
$ (this). Prev (). Show ();
$ (this). Prev (). focus ();
$ (this). Hide ();
});
$ (this). blur (function () {
if ($ (this). val () = = "") {$ (this). Hide (); $ (this). Next (). Show (); }
});
}
Perhaps not quite perfect, I hope you will point out.

HTML5 placeholder in ie10 below pseudo hint

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.