Thursday, November 27, 2014

Placeholder attribute for IE Hack



HTML5 introduced the "placeholder" attribute on input elements, which allows to display a greyed-out default text. But Sadly the Internet Explorer, including IE 9 does not support it. I got a solution. Just try this.


if(navigator.appVersion.match(/MSIE [\d.]+/)){

    var placeholder = $('input[type=text]').attr('placeholder');
    var placeholderText = placeholder;


    $('input[type=text]').val(placeholderText);
    $('input[type=text]').blur(function(){
        $(this).val() == '' ? $(this).val(placeholderText) : false;
    });


    $('input[type=text]').focus(function(){
        $(this).val() == placeholderText ? $(this).val('') : false;
    });
}

1 comment:

  1. I ADAMS KEVIN, a representative Aiico Insurance plc, we trust and respect for individual differences in day out a loan. We will provide 2% of the loan's interest rate. If you are interested in this business contact us by e-mail: (adams.credi@gmail.com) now transfer their loan documents issued properly. Do you need a loan to set up business or school if you are very welcome to Aiico Insurance plc. You can also contact us by e-mail: (adams.credi@gmail.com). We first week can request a balance transfer.

    DO YOU NEED LOAN FOR PERSONAL BUSINESS? IF YOU CONTACT YOUR EMAIL ABOVE TO PROCEED WITH YOUR LOAN TRANSFER IMMEDIATELY OK.

    ReplyDelete