首页 > 其他 > 详细

兼容IE8 input的placeholder的文字显示

时间:2016-12-25 20:42:24      阅读:186      评论:0      收藏:0      [点我收藏+]
if( !(‘placeholder‘ in document.createElement(‘input‘)) ){          
    $(‘input[placeholder],textarea[placeholder]‘).each(function(){              
        var that = $(this),               
        text= that.attr(‘placeholder‘);               
        // console.log(text);            
        if(that.val()===""){                   
            that.val(text).addClass(‘placeholder‘);               
        }               
        that.focus(function(){                   
            if(that.val()===text){                     
                that.val("").removeClass(‘placeholder‘);                   
            }               
        }).blur(function(){                
            if(that.val()===""){                    
                that.val(text).addClass(‘placeholder‘);                   
            }               
        }).closest(‘form‘).submit(function(){                   
            if(that.val() === text){                     
            that.val(‘‘);                   
            }               
        });               
    });       
}

 

兼容IE8 input的placeholder的文字显示

原文:http://www.cnblogs.com/wuxibolgs329/p/6220395.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!