jQuery扩展extend一
把这个扩展写在这里,以后要是忘了可以回头查看。
(function(j) {// 这里的j是一个形参,表示传入的jQuery对象,j可以任意填写
j.extend({// 相当于给jQuery对象加上了一个属性readName,而这个属性是一个方法
// 通过传入的jQuery对象,
// 然后再用jQuery.exetend(functionName:function(){});
// 这种方式扩展jQuery的方法, // 使用方法或者说是调用方式:$.readName('I am 你大爷 ');
this_ : this,
timeId: null,
flagWyl:null,
readName : function(name) {
// alert(typeof this);
// alert(typeof window);
// alert(typeof this.name);
console.log(typeof this.name);
console.log(typeof this);
if (name == null || name == undefined || name == '') {
// alert('没有入参name!');
console.log('没有入参name!') } else {
// alert('入参name:'+name);
console.log('入参name:' + name);
}
},
//封装提示的内容:
Walert:function(msg){
alert('系统异常:'+msg);
},
/**
* toId:需要设置时间的表单的Id,
* flag:true的时候,设置本地时间格式,false,设置成通用格式
*/
WsetTime:function(toId,flag){
var d = new Date();
// window.setInterval('$.WsetTime('+toId+','+flag+')',10000);
if(flag){
$('#'+toId+'').attr('value',d.toLocaleString());
}else{
$('#'+toId+'').attr('value',d.toTimeString());
}
// $.this_ = this;//把当前对象传给 存储临时变量的对象,当前对象即WsetTime()这个函数
$.timeId = toId;
$.flagWyl = flag;
},
/**
* 设置时间间隔
*/
WsetGap:function(intervalTime){
if($.timeId){
window.setInterval('$.WsetTime('+$.timeId+','+$.flagWyl+')',intervalTime);
}
},
/**
* 封装console.log()方法
*/
logW:function(paras){
console.log('logW:'+paras);
} })
})(jQuery)// 这个jQuer一定要这样写,表示传入jQuery对象
以上的代码的前提是要在项目中引入jQuery.js,以上的js链接:myJqueryExtend.js
jQuery扩展extend一的更多相关文章
- jQuery.extend()、jQuery.fn.extend()扩展方法示例详解
jQuery自定义了jQuery.extend()和jQuery.fn.extend()方法.其中jQuery.extend()方法能够创建全局函数或者选择器,而jQuery.fn.extend()方 ...
- jquery属性操作,应用,事件,扩展extend,动画效果(二)
一.相关知识点总结1.CSS .css() - .css("color") -> 获取color css值 - .css("color", & ...
- jquery扩展的两个方法与区别 $.extend $.fn.extend
jQuery.extend:Query本身的扩展方法 jQuery.fn.extent(Object) jquery 所选对象扩展方法 jQuery.extend 我们先把jQuery看成了一个类,这 ...
- jquery插件的2种扩展开发(jQuery.extend和jQuery.fn.extend的区别)
1.类级别 jQuery.extend(object) 类级别你可以理解为拓展jquery类,最明显的例子是$.ajax(...),相当于静态方法. 开发扩展其方法时使用$.extend方法,即jQu ...
- jquery源码解析:jQuery扩展方法extend的详解
jQuery中要扩展方法或者属性都是通过extend方法实现的.所谓的jQuery插件也是通过extend方法实现的. jQuery.extend扩展的是工具方法,也就是静态方法.jQuery.fn. ...
- jQuery.extend()、jQuery.fn.extend()扩展方法具体解释
版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/dreamsunday/article/details/25193459 jQuery自己定义了jQu ...
- JQuery的extend扩展方法
jQuery.extend 函数使用详解 JQuery的extend扩展方法: Jquery的扩展方法extend是我们在写插件的过程中常用的方法,该方法有一些重载原型,在此,我们一起去 ...
- jQuery插件扩展extend的实现原理
相信每位前端的小伙伴对jQuery都不陌生吧,它最大的魅力之一就是有大量的插件,去帮助我们更轻松的实现各种功能. 前几天晚上,闲来无事,就自己动手写了个简单的jQuery插件,功能很简单,只是让选定的 ...
- jquery.fn.extend与jquery.extend--(初体验二)
1.jquery.extend(object); 为扩展jQuery类本身.为类添加新的方法. jquery.fn.extend(object);给jQuery对象添加方法. $.extend({ a ...
随机推荐
- discuz_style_default.xml 修改
<?xml version="1.0" encoding="ISO-8859-1"?> <root> <item id=" ...
- Struts 上下文
Struts 上下文 ActionContext .ServletActionContext 是继承关系 ActionContext ActionContext context = Action ...
- oracle 11g RAC ocfs2
http://oracle-base.com/articles/linux/ocfs2-on-linux.php http://oracle-base.com/articles/11g/oracle- ...
- uva-12657 - Boxes in a Line(双向链表)
12657 - Boxes in a Line You have n boxes in a line on the table numbered 1 . . . n from left to righ ...
- java实现 阿拉伯数字转换为汉字数字 算法
package test; public class NumberFormatTest { static String[] units = { "", "十", ...
- (HLS播放器之中的一个)HLS协议之M3U8解析
參照 http://tools.ietf.org/html/draft-pantos-http-live-streaming-08, 能够对M3U8有比較系统的认识. HLS(HTTP Live St ...
- HDU2546:饭卡(01背包)
HDU2546:饭卡 http://acm.hdu.edu.cn/showproblem.php?pid=2546 当我们遇到问题选择物体的价值和顺序相关时就需要,排完序后对其01处理.这题因为当我们 ...
- JBoss 系列七十:一个简单的 CDI Web 应用
概述 本文通过一个简单的 CDI Web 应用演示dependency injection, scope, qualifiers 以及EL整合.应用部署完成后我们可以通过http://localhos ...
- php学习笔记(2)
1.算数运算 <?php $a = 8; $b = 2; $c = 3; echo $a+$b."<br>\n"; echo $a-$b."<br ...
- IOS 表视图(UITableVIew)的使用方法(7)表视图的编辑功能(拖拉调整排序位置)
除了每个单元行左边的删除和新增图标,UITableView还支持在单元行的右侧显示一个供用户拖拉调整排序位置的控件. 不过如果要显示此控件,UITableView的数据源需要实现以下的方法. -(vo ...