为什么会起作用
$("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()
不会吗?我不懂。有人可以向我解释一下吗?提前谢谢
答案 0 :(得分:0)
您的问题看起来像这一行:$("#"+self.id+"").show();
(不需要最后一个“”,所以$("#"+self.id).show()
,但这不是问题)
self
是this
,它是openWith
函数,显然没有DOM元素ID。