比如,$(document).on('click','#id1',function(){
dosomething;
});
$(document).on('click','#id2',function(){
dosomething;
});
这样看上去不是很舒服,能不能写成
$(document).on('click','#id1',functin1());
$(document).on('click','#id2',functin2());
var function1 = ;var function2=..;
..的形式,我直接把something提取成function显示has no method 'apply'错误,不是很懂js的面向对象机制,求指点一下二jQuery事件绑定面向对象
dosomething;
});
$(document).on('click','#id2',function(){
dosomething;
});
这样看上去不是很舒服,能不能写成
$(document).on('click','#id1',functin1());
$(document).on('click','#id2',functin2());
var function1 = ;var function2=..;
..的形式,我直接把something提取成function显示has no method 'apply'错误,不是很懂js的面向对象机制,求指点一下二jQuery事件绑定面向对象
$(document).on('click','#id2',functin2);
var function1 = function ()
{
};
var function2 = function ()
{
};
去掉括号就是了
var function1 = function ()
{
};
var function2 = function ()
{
};
$(document).on('click','#id1',functin1);
$(document).on('click','#id2',functin2);