• 兼容ie的placeholder设置


    html5的placeholder在ie上不被支持,解决的方法

    直接在网页里添加

    <!--兼容ie的placeholder-->
    <script src="static/js/placeholder.js"></script>

    就可以了

     1 function isPlaceholder(){
     2  var input = document.createElement('input');
     3  return 'placeholder' in input;
     4 }
     5 
     6 if (!isPlaceholder()) {//不支持placeholder 用jquery来完成
     7  $(document).ready(function() {
     8      if(!isPlaceholder()){
     9          $("input").not("input[type='password']").each(//把input绑定事件 排除password框
    10              function(){
    11                  if($(this).val()=="" && $(this).attr("placeholder")!=""){
    12                      $(this).val($(this).attr("placeholder"));
    13                      $(this).focus(function(){
    14                          if($(this).val()==$(this).attr("placeholder")) $(this).val("");
    15                      });
    16                      $(this).blur(function(){
    17                          if($(this).val()=="") $(this).val($(this).attr("placeholder"));
    18                      });
    19                  }
    20          });
    21          //对password框的特殊处理1.创建一个text框 2获取焦点和失去焦点的时候切换
    22          var pwdField = $("input[type=password]");
    23          var pwdVal  = pwdField.attr('placeholder');
    24          pwdField.after('<input id="pwdPlaceholder" type="text" value='+pwdVal+' autocomplete="off" class="form-control" />');
    25          var pwdPlaceholder = $('#pwdPlaceholder');
    26          pwdPlaceholder.show();
    27          pwdField.hide();
    28          
    29          pwdPlaceholder.focus(function(){
    30           pwdPlaceholder.hide();
    31           pwdField.show();
    32           pwdField.focus();
    33          });
    34          
    35          pwdField.blur(function(){
    36           if(pwdField.val() == '') {
    37            pwdPlaceholder.show();
    38            pwdField.hide();
    39           }
    40          });
    41          
    42      }
    43  });
    44  
    45 }
    View Code
  • 相关阅读:
    jquery总结
    Reporting Services子报表
    Reporting Services分组及Toggle
    Reporting Services报表钻取
    Reporting Services环境
    两种很有用的组件
    Reporting Services正确显示页码
    Reporting Services发布
    Java面试题
    BigInteger引申的一个访问权限控制解决方案
  • 原文地址:https://www.cnblogs.com/zhangruiyun/p/3885868.html
Copyright © 2020-2023  润新知