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

jquery自定义函数的更多相关文章

  1. jquery自定义函数的多种方法

    在jquery中自定义函数你会吗?今天抽时间写了几个,个人感觉还不错,喜欢的朋友可以了解下   复制代码 代码如下: //方法定义 $.windowbox = { //定义一个方法aa aa: fun ...

  2. jQuery 自定义函数写法分享

    时间:02月20日   自定义主要通过两种方式实现$.extend({aa:function(){}});$.fn.extend({aa:function(){}});调用的方法分别是:$.aa(); ...

  3. jQuery自定义函数验证邮箱格式

    jQuery.fn.checkEmail = function() { // 自定义jQuery方法 var email_val = $(this).val(); reg = /^\w+([-+.]\ ...

  4. 转载 jQuery和js自定义函数和文件的方法(全网最全)

    jQuery和js自定义函数和文件的方法(全网最全)    版权声明:本文为像雾像雨又像风_http://blog.csdn.net/topdandan的原创文章,未经允许不得转载. https:// ...

  5. 利用jQuery扩展接口为jQuery框架定义了两个自定义函数,然后调用这两个函数

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  6. 深入学习jQuery自定义插件

    原文地址:jQuery自定义插件学习 1.定义插件的方法 对象级别的插件扩展,即为jQuery类的实例增加方法, 调用:$(选择器).函数名(参数);      $(‘#id’).myPlugin(o ...

  7. jquery自定义插件——以 选项卡插件为例

    一直打算尝试自定义插件,终于付诸实践了,现在把内容发表出来,与大家共勉. 我是根据自己正在用的插件,模仿其源码,实现的自定义插件,完成之后,在网上看相关资料,对自定义插件部分,有了更明确的认识. jq ...

  8. jQuery.noConflict() 函数

    jQuery.noConflict()函数用于让出jQuery库对变量$(和变量jQuery)的控制权. 一般情况下,在jQuery库中,变量$是变量jQuery的别名,它们之间是等价的,例如jQue ...

  9. jQuery自定义插件

    jQuery自定义插件 jQuery自定义插件按照功能分类,可以分为三类, 1>封装对象方法的插件,(也就是基于某个DOM元素的jQuery对象,局部的) 2>封装全局函数的插件,   ( ...

随机推荐

  1. 7-27 Codeforces Round #499 (Div. 2)

    C. Fly 链接:http://codeforces.com/group/1EzrFFyOc0/contest/1011/problem/C 题型:binary search .math. 题意:总 ...

  2. 王之泰201771010131《面向对象程序设计(java)》第十四周学习总结

    第一部分:理论知识学习部分 第12章 Swing用户界面组件 12.1.Swing和MVC设计模式 a 设计模式初识b 模型—视图—控制器模式c Swing组件的模型—视图—控制器分析 12.2布局管 ...

  3. 史上最全!Selenium元素定位的30种方式

    Selenium对网页的控制是基于各种前端元素的,在使用过程中,对于元素的定位是基础,只有准去抓取到对应元素才能进行后续的自动化控制,我在这里将对各种元素定位方式进行总结归纳一下. 这里将统一使用百度 ...

  4. Latex 经常见到的问题和解决方法

    Latex 经常见到的问题和解决方法 2017-04-10  22:05:48 [资源下载]Texlive 2018 下载地址:http://mirror.lzu.edu.cn/CTAN/system ...

  5. vue使用$http服务端收不到参数

    老夫子我正在憋方案书,听到身后传来细软的声音:“李哥,我这有个Bug调了很长时间了,您能帮我看一下吗?”.说这话的是我的好朋友,公司新来的前端小妹伊万卡.我起身向她走去,看到因长时间调试Bug漂亮的脸 ...

  6. Apache 配置多个端口多站点(Linux)

    for apache2 configuration: by default, apache is configured 80 port for the default web site. follow ...

  7. 记 Swagger 2

    Maven坐标: <dependency> <groupId>io.springfox</groupId> <artifactId>springfox- ...

  8. P3953 逛公园

    传送门 花了一个下午才 A 的毒瘤题 思路: 这题需要建两个图,一个正向图,一个反向图. 先在正向图上跑一遍 dijkstar ,计算出每个点到 点1 的最短路径 . 然后在反向图上开始记忆化搜索: ...

  9. logic pro x 下载

    https://pan.baidu.com/s/1gfO5KOV

  10. CentOS7.X怎样更新yum源

    1. 备份原来的yum源 $sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo-backup 2.设 ...