代码解决 有些浏览器不支持placeholder特性的问题

来源:互联网 发布:三菱fx2n pid编程手册 编辑:程序博客网 时间:2024/06/01 18:10
//代码解决 有些浏览器不支持placeholder特性的问题$(document).ready(function(){    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('');                    }                });        });    }});

0 0
原创粉丝点击