/**
*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. 求最近点对算法分析 closest pair algorithm

    这个帖子讲得非常详细严谨,转一波. http://blog.csdn.net/lishuhuakai/article/details/9133961

  2. python第二天3.1

    算数运算符arithmetic operator: + - * / % % : 取余,取模.取的是第一个操作数和第二个操作数除法的余数.整除结果为0. 10 % 3              1 10 ...

  3. Bigger-Mai 养成计划,前端基础学习之HTML

    HTML 超文本标记语言(Hyper Text Markup Language) 1.一套规则,浏览器认识的规则. 2.开发者: 学习Html规则 开发后台程序: - 写Html文件(充当模板的作用) ...

  4. CF685B Kay and Snowflake 贪心

    CF685B Kay and Snowflake 链接 CF 题目大意 给你一颗树,询问子树的重心 思路 贪心? 重心肯定是向上走的,所以直接向上跳就好了. 不优秀的时候就不要跳了 ,因为以后也不能更 ...

  5. snmp模拟器snmpsid使用

    snmpsim使用 安装 pip install snmpsim 简单使用 生成snmpwalk文件: snmpwalk -v2c -c 'password' -ObentU 218.200.x.15 ...

  6. pycharm的pip安装问题,需要确认适合IDE的pip版本

    python 报错     AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader' 解决方法 ...

  7. [MySQL] timestamp和datetime的区别

    建表语句如下: create table strong_passwd_whitelist( id int unsigned not null auto_increment, email_id int ...

  8. gcc 无法编译c17程序解决办法

    1.保证将gcc程序升级到7.1以上. 2.如果用命令行手工编译,就多加个参数-std=c++17,例如命令应该是: "g++" -std=c++17  "text.cp ...

  9. druid 连接池加密算法

    package juint; import com.alibaba.druid.filter.config.ConfigTools; public class DruidTest { public s ...

  10. Mysql 索引之B+tree

    InnoDB使用的是聚簇索引,将主键组织到一棵B+树中,而行数据就储存在叶子节点上,若使用"where id = 14"这样的条件查找主键,则按照B+树的检索算法即可查找到对应的叶 ...