对象中的JQuery

时间:2013-05-14 11:40:59

标签: jquery ajax object

为什么会起作用

$("body").on("click",".open_popup",function(event){

        event.preventDefault();

        $("#form1").show(); 

    })

但对象内部的代码相同,如下:

var popUpFormulario = {

              openWith: function () {
        self=this;

        $("body").on("click",".open_popup",function(event){

            event.preventDefault();

            $("#"+self.id+"").show();   

        })
    }

然后像这样调用函数

popUpFormulario.openWith() 
不会吗?我不懂。有人可以向我解释一下吗?提前谢谢

1 个答案:

答案 0 :(得分:0)

您的问题看起来像这一行:$("#"+self.id+"").show();(不需要最后一个“”,所以$("#"+self.id).show(),但这不是问题)

selfthis,它是openWith函数,显然没有DOM元素ID。