jQuery.fn.foobar=function(){
//do something
}
/**可选,创建帮助方法**/
jQuery.fooBar={
height:5,
calculateBar =function(){},
checkDependencies = function(){}
}
/**可选:创建可选的参数**/
jQuery.fn.foobar = function(options){
var settings = {
value:5,
name:'pete',
bar:655
};
if(options){
jQuery.extend(settings,options);
}
}
/**编写插件,查看radio标签的checked属性**/
$("input[@type='checkbox']").each(function(){//这几句话有什么作用啊
this.checked = true;
//取消
this.checked = false;
//点击了就取消,反之则点击
this.checked = !this.checked;
})
/**插件**/
$fn.check = function(){
return this.each(function(){
this,checked = true;
})
}
/**使用**/
$("input[@type = 'checkbox']").check();
//还可以在写一个uncheck()方法,通过参数字符来判断
$fn.check=function(mode){
var mode = mode||'on',
return this.each(function(){
switch(mode){
case 'on':
this.checked=true;
break;
case 'off':
this.checked= false;
break;
case 'toggle':
this.checked = !this.checked;
break;
}
})
}
/**使用**/
$("input[@type='checkbox']").check();
$("input[@type='checkbox']").check('on');
$("input[@type='checkbox']").check('off');
$("input[@type='checkbox']").check('toggle');
$fn.rateMe = function(options){
var container = this;
var settings = {
url = rate.php//如果没有,这里就默认设置
};
if(options){
$.extend(settings.options);
}
return this;
}