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;
};
jquery自定义函数的更多相关文章
- jquery自定义函数的多种方法
在jquery中自定义函数你会吗?今天抽时间写了几个,个人感觉还不错,喜欢的朋友可以了解下 复制代码 代码如下: //方法定义 $.windowbox = { //定义一个方法aa aa: fun ...
- jQuery 自定义函数写法分享
时间:02月20日 自定义主要通过两种方式实现$.extend({aa:function(){}});$.fn.extend({aa:function(){}});调用的方法分别是:$.aa(); ...
- jQuery自定义函数验证邮箱格式
jQuery.fn.checkEmail = function() { // 自定义jQuery方法 var email_val = $(this).val(); reg = /^\w+([-+.]\ ...
- 转载 jQuery和js自定义函数和文件的方法(全网最全)
jQuery和js自定义函数和文件的方法(全网最全) 版权声明:本文为像雾像雨又像风_http://blog.csdn.net/topdandan的原创文章,未经允许不得转载. https:// ...
- 利用jQuery扩展接口为jQuery框架定义了两个自定义函数,然后调用这两个函数
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 深入学习jQuery自定义插件
原文地址:jQuery自定义插件学习 1.定义插件的方法 对象级别的插件扩展,即为jQuery类的实例增加方法, 调用:$(选择器).函数名(参数); $(‘#id’).myPlugin(o ...
- jquery自定义插件——以 选项卡插件为例
一直打算尝试自定义插件,终于付诸实践了,现在把内容发表出来,与大家共勉. 我是根据自己正在用的插件,模仿其源码,实现的自定义插件,完成之后,在网上看相关资料,对自定义插件部分,有了更明确的认识. jq ...
- jQuery.noConflict() 函数
jQuery.noConflict()函数用于让出jQuery库对变量$(和变量jQuery)的控制权. 一般情况下,在jQuery库中,变量$是变量jQuery的别名,它们之间是等价的,例如jQue ...
- jQuery自定义插件
jQuery自定义插件 jQuery自定义插件按照功能分类,可以分为三类, 1>封装对象方法的插件,(也就是基于某个DOM元素的jQuery对象,局部的) 2>封装全局函数的插件, ( ...
随机推荐
- VC++ 实现程序重启
转载:https://blog.csdn.net/what951006/article/details/72729448 一.创建一个Win32项目 二.窗口处理函数中,Create窗口时创建一个按钮 ...
- Python连接redis时要注意的点
一.一般连接redis情况 from redis import Redis # 实例化redis对象 rdb = Redis(host='localhost', port=6379, db=0) rd ...
- 记 Arduino 之 Hello World 篇(Getting Started)
本文仅为入门实验,甚至谈不上研究的程度.目的是:记录如何烧录程序到 Arduino 主板,以及通过一些简单例程,找到 Arduino 开发的感觉. 开发环境:Ardunio IDE(用于编译.上传运行 ...
- luogu准备复习(学习)题单
矩阵乘法 P1306 exbsgs P4195 网络流(割点) P1345 主席树 P3302
- Yaml语法使用
YAML概要 1. 认识 YAML YAML是一个类似 XML.JSON 的标记性语言.YAML 强调以数据为中心,并不是以标识语言为重点.因而 YAML 本身的定义比较简单,号称“一种人性化的数据格 ...
- python转义符
- Unity --- 如何简单的判断图片是否含有 alpha channel
var texImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter; if (texImporter.DoesSourceT ...
- stm32WB55xx 外设资源
1.FLASH(闪存) 2.Radio System(无线系统:兼容BLE5.0与IEEE802.15.4标准,由2.4GHz射频前端.BLE和IEEE802.15.4物理层控制器组成,无线低功耗协议 ...
- PPI | protein-protein interaction | 蛋白互作分析
STRING database的挖掘 这个数据库绝对是做实验人的宝藏,里面包含了各种蛋白互作关系,不用做实验就有一大堆证据. IPA了解一下,收费的高端分析软件,大部分就是整合的这个数据库,很多大佬喜 ...
- time series 时间序列 | fractional factorial design 部分要因试验设计
作业: 1) A plot of data from a time series, which shows a cyclical pattern – please show a time series ...