defaults

jquery记录

落花浮王杯 提交于 2019-11-26 17:26:18
1:插件写法 (1)对HTML标记或页面元素进行扩展,使用这种插件的扩展方式,在使用此插件时,需要首先引用经过JQuery包装的页面元素,如:$("#tableId").Method()。 (function($){ //扩展这个方法到jquery $.fn.extend({ //插件名称 one:function(options){//参数 var defaults = {//默认参数 animatePadding:"30px", defaultPadding:"0px", hoverColor:"red" } options = $.extend(defaults,options);//合并参数 return this.each(function(){//遍历匹配的每个对象 //...要执行的js var me = $("li",this); $(me).hover(function(){ $(this).css("color",defaults.hoverColor); $(this).animate({"paddingLeft":defaults.animatePadding},{queue:false,duration:200}); },function(){ $(this).css("color",""); $(this).animate({"paddingLeft"

jquery记录

喜欢而已 提交于 2019-11-26 17:26:17
1:插件写法 (1)对HTML标记或页面元素进行扩展,使用这种插件的扩展方式,在使用此插件时,需要首先引用经过JQuery包装的页面元素,如:$("#tableId").Method()。 (function($){ //扩展这个方法到jquery $.fn.extend({ //插件名称 one:function(options){//参数 var defaults = {//默认参数 animatePadding:"30px", defaultPadding:"0px", hoverColor:"red" } options = $.extend(defaults,options);//合并参数 return this.each(function(){//遍历匹配的每个对象 //...要执行的js var me = $("li",this); $(me).hover(function(){ $(this).css("color",defaults.hoverColor); $(this).animate({"paddingLeft":defaults.animatePadding},{queue:false,duration:200}); },function(){ $(this).css("color",""); $(this).animate({"paddingLeft"

重新封装通用ajax

青春壹個敷衍的年華 提交于 2019-11-26 16:19:52
jQuery.billow = { getAjax: function (opts, successfn, errorfn) { //--设置默认参数 var defaults = { // 访问方式:分为POST/GET方式,默认为GET; method: 'GET', // 访问地址 url: '', // 向服务器请求发送的数据 data: '', // 默认加密,此处为自定义 // encrypt:true, // 是否异步:true/false,默认值:true; async: true, // 是否缓存,默认缓存 cache: true, // HTTP头信息,默认值:'application/x-www-form-urlencodedcharset=utf-8'; // application/json contentType: 'application/x-www-form-urlencoded; charset=UTF-8', // 接收服务器返回的数据类型:JSON、JSONP、text。默认json dataType: 'json' }; // 用户参数覆盖默认参数 for (var key in opts) { defaults[key] = opts[key]; } // 处理method defaults.method = defaults.method

如何制作JQuery Plugin 插件

五迷三道 提交于 2019-11-26 11:50:51
JQuery Plugin插件,如果大家不明白什么是JQuery插件或都不清楚如何编写可以查看其官方的网站: jQuery Authoring Guidelines 好了,下面有一些我觉得想做一个好的插件必须应有的要求: 1、在JQuery命名空间下声明只声明一个单独的名称 2、接受options参数,以便控制插件的行为 3、暴露插件的默认设置 ,以便外面可以访问 4、适当地将子函数提供给外部访问调用 5、保持私有函数 6、支持元数据插件 下面将逐条地过一遍: 只声明一个单独的名称 这表明是一个单独的插件脚本。如果你的脚本包含多个插件或者是互补的插件(像$.fn.doSomething()和$.undoSomething()),那么你可以根据要求声明多个名称。但一般情况下,力争用单一的名称来维持插件现实的所有细节。 在本例中,我们将声明一个叫“hilight”的名称 // 插件的定义 $.fn.hilight = function ( options ){ // 这里就是插件的实现代码了... }; 然后我们可以像这样调用它: $ ( "divTest" ). hilight (); 接受一个options参数,以便控件插件的行为 $ . fn . hilight = function ( options ){ var defaults = { foreground : 'red'

How to load packages in R automatically?

懵懂的女人 提交于 2019-11-26 04:38:23
问题 Could you suggest me a way for loading packages in R automatically? I mean, I want to start a session in R without needing to use library(\'package name\') several times. Suppose I downloaded all packages I\'ll want to use the next time I start R. 回答1: Put library(foo) in your .Rprofile file or set R_DEFAULT_PACKAGES : see ?Rprofile ... In particular (because ?Rprofile is long and potentially intimidating): If you want a different set of packages than the default ones when you start, insert a

Force R not to use exponential notation (e.g. e+10)?

微笑、不失礼 提交于 2019-11-26 00:23:49
问题 Can I force R to use regular numbers instead of using the e+10 -like notation? I have: 1.810032e+09 # and 4 within the same vector and want to see: 1810032000 # and 4 I am creating output for an old fashioned program and I have to write a text file using cat . That works fine so far but I simply can\'t use the e+10 notation there. 回答1: This is a bit of a grey area. You need to recall that R will always invoke a print method, and these print methods listen to some options. Including 'scipen' -