zoukankan      html  css  js  c++  java
  • jquery自定义函数

    /**
    *jquery 的拓展方法
    */
    /**
    * 给btn 添加去除disabled
    */
    $.fn.disabled = function() {
      $(this).each(function(index,em){
      var _this = $(em);
      if(_this.is('button')||_this.is('input[type="button"]')){
        _this.prop('disabled','disabled');
        _this.css('cursor','not-allowed');
        _this.removeClass('u-btnBlue');
        _this.css({'background': '#1f5183','color': '#fff'});
      }else if (_this.is('input')) {
        _this.prop('disabled','disabled');
      }else if (_this.is('.u-btn')) {
        _this.addClass('u-btnDisable');
        var _width = _this.outerWidth();
        var _height = _this.outerHeight();
        var _zIndex = _this.css("z-index");
        console.log(parseFloat(_zIndex));
        _this.css('position','relative');
        var mark = $("<div class='mark'></div>").css({"z-index":_zIndex+1,"background-color":"transparent"});
        _this.append(mark);
        mark.click(function(){
        return false;
        });
      };
    });
    };

    /**
    * 格式化后转number字符串
    * @param {Object} symbol 货币标识
    * @param {Object} thousand 分隔符
    * @param {Object} decimal 小数点符号
    */
    String.prototype.formatMoneyToNumber = function(symbol, thousand, decimal) {
      var string = this;
      string = string || '0';
      symbol = symbol || "";
      symbol = symbol !== undefined ? symbol : "";
      thousand = thousand || ",";
      decimal = decimal || ".";
      return string.replace(symbol, '').replace(new RegExp(thousand,"g"), '').replace(decimal, '.');
    };

    Number.prototype.formatMoney = function(places, symbol, thousand, decimal) {
      places = places || 0;
      places = !isNaN( places = Math.abs(places)) ? places : 2;
      symbol = symbol !== undefined ? symbol : "";
      thousand = thousand || ",";
      decimal = decimal || ".";
      var number = this,negative = number < 0 ? "-" : "", i = parseInt( number = Math.abs(+number || 0).toFixed(places), 10) + "", j = ( j = i.length) >     3 ? j % 3 : 0;
      number = symbol + negative + ( j ? i.substr(0, j) + thousand : "") + i.substr(j).replace(/(d{3})(?=d)/g, "$1" + thousand) + ( places ? decimal +   Math.abs(number - i).toFixed(places).slice(2) : "");
      return number == 0?0:number;
    };

  • 相关阅读:
    Spring Boot2 系列教程(二十)Spring Boot 整合JdbcTemplate 多数据源
    Spring Boot 如何给微信公众号返回消息
    Spring Boot2 系列教程(十九)Spring Boot 整合 JdbcTemplate
    Spring Boot2 系列教程(十八)Spring Boot 中自定义 SpringMVC 配置
    Spring Boot 开发微信公众号后台
    Spring Boot2 系列教程(十七)SpringBoot 整合 Swagger2
    Spring Boot2 系列教程(十六)定时任务的两种实现方式
    Spring Boot2 系列教程(十五)定义系统启动任务的两种方式
    Spring Boot2 系列教程(十四)CORS 解决跨域问题
    JavaScript二维数组
  • 原文地址:https://www.cnblogs.com/lizihao/p/6594566.html
Copyright © 2011-2022 走看看