比如,$(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事件绑定面向对象

解决方案 »

  1.   

    $(document).on('click','#id1',functin1);
    $(document).on('click','#id2',functin2);
    var function1 = function ()
    {
    };
    var function2 = function ()
    {
    };
      

  2.   

    $(document).on('click','#id1',functin1);
    去掉括号就是了
      

  3.   

    应该这样
    var function1 = function ()
    {
    };
    var function2 = function ()
    {
    };
    $(document).on('click','#id1',functin1);
    $(document).on('click','#id2',functin2);
      

  4.   

    可是还是提示我Uncaught TypeError: Object #id1 has no method 'apply',我的问题是怎么在function1中获取事件点击的dom对象 
      

  5.   

    好吧 我发现在 function1 里面 this竟然是指向dom对象的 看来还是对js了解的太少了啊