解决方案 »
- 求助各位大侠js取css中的class元素
- 请问如何选出链接均为JavaScript:void(0) 但onclick不同的链接
- jquery怎样才能把注释也一同load进来?
- 请教IE和Firefox兼容的问题
- js中的invoke 疑问??
- 帮我看看这段正则替换哪里错了?
- 很急:利用javascript把url参数以post方式传到另一个页面
- 那位大侠有企业门户网站的实例??
- 谁知道为什么表单中的参数“method”取get或post后点“发送”怎会没有区别,谢谢!
- 数组排序
- jsp <c:forEach>循环页面加载速度慢
- <script type="text/javascript"> function test(){ var a=document.getElementById("
this.each(function () {
……
});
}
if (typeof options == 'string') {
switch (options) {
case 'subMethod': return this.each(function () { alert('子方法'+params); /*你的子方法代码*/ });
}
}
var defaults = {
// ……
};
var opts = $.extend(defaults, options); return this.each(function () {
// ……
});
}
//调用
var $input = $('#input').method('subMethod',123);这样写,而不是你那样
var $input=$('#input').method(); //我必须先生成控件,并获得控件的对象 $input
……$input.subMethod();//在其它地方可能会调用这个对象的一个子方法,调用后其实是这个空间本身的一些刷新或者数据重载等
set_: function(jq, option){
return jq;
}
});
<input type="text" id="input" />
<script type="text/javascript">
$.fn.method = function (options) {
var defaults = {
name: "123"
//……
};
var opts = $.extend(defaults, options);
this.each(function () {
//……
});
$this = this;
return {
subMethod: function (){
$this.each(function () {
$(this).val(opts.name);
});
}
};
};//调用
var $input=$('#input').method();
$input.subMethod();
</script>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<input type="text" id="input" />
<script type="text/javascript">
$.fn.method = function (options) {
var defaults = {
name: "123"
//……
};
var opts = $.extend(defaults, options);
this.each(function () {
//……
});
var $this = this;
return {
subMethod: function (){
$this.each(function () {
$(this).val(opts.name);
});
}
};
};//调用
var $input=$('#input').method();
$input.subMethod();
</script>