function is_true(){ return ‘placeholder‘ in document.createElement(‘input‘); }
实例:placeholder在低版本IE浏览器下兼容性解决
<script type="text/javascript"> 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); } that.focus(function(){ if(that.val()===text){ that.val(""); } }).blur(function(){ if(that.val()===""){ that.val(text); } }).closest(‘form‘).submit(function(){ if(that.val() === text){ that.val(‘‘); } }); }); } </script>
时间: 2024-10-13 01:00:42