Showing Placeholder text for password field in IE

前端 未结 8 1140
悲&欢浪女
悲&欢浪女 2020-12-03 23:19

I know there is a ton of placeholder questions, but I am trying to perfect mine.

My current code works great and does what it\'s supposed to. The problem is, when I

8条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-03 23:20

    Here my plugin :

    if(jQuery.support.placeholder==false){
        // No default treatment
        $('[placeholder]').focus(function(){
            if($(this).val()==$(this).attr('placeholder'))
                $(this).val('');
            if($(this).data('type')=='password')
                $(this).get(0).type='password';
        });
        $('[placeholder]').blur(function(){
            if($(this).val()==''){
                if($(this).attr('type')=='password'){
                    $(this).data('type','password').get(0).type='text';
                }
                $(this).val($(this).attr('placeholder'));
            }
        }).blur();
    }
    

提交回复
热议问题