/*IE8支持placeholder占位符*/
if( !('placeholder' in document.createElement('input')) ){
    $('input[placeholder],textarea[placeholder]').each(function(){
        var that = $(this),
        text= that.attr('placeholder');
        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('');
            }
        });
    });
}

相关文章:

  • 2021-07-24
  • 2022-01-15
  • 2021-09-22
  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-02
  • 2022-12-23
  • 2021-08-16
  • 1970-01-01
  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
相关资源
相似解决方案