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;
    };

  • 相关阅读:
    04.DRF-开发REST 接口
    03.DRF-设计方法
    02.DRF-认识RESTful
    01.DRF-Web应用模式
    14.Django-xadmin和富文本编辑器
    13.Django-分页
    12.Django-admin
    11.Django-form表单上传文件
    android 基于wifi模块通信开发
    android蓝牙通讯开发(详细)
  • 原文地址:https://www.cnblogs.com/lizihao/p/6594566.html
Copyright © 2011-2022 走看看