2011-11-16 85 views
0

以下是我的jQuery功能,如有可能请更正,并让我知道我错在哪里。萤火虫控制台错误:无效标签

$("#id").click(function() { 
     start : appendLayout(this.id) // invoking another function to do and this part is working. 
     stop : (function(){ 
        if(true){ alert("please create project"); } 
       }) // not working, getting error in firbug console if i change anything 

    }); 
+3

什么是开始还是停止?你在这里显示的是无效的JavaScript。 –

+0

好的。感谢Darin。 – user1010399

+0

我正试图在两个事件中执行任务,这就是为什么我使用'start stop' – user1010399

回答

1

你想做什么?你正在一个函数中创建一些属性,这不是一个对象。

这是错误的:

function() { 
     firstName: 'Saeed', 
     lastName: 'Neamati' 
    }); 

这是创建对象的正确方法:

var person = { 
    firstName: 'Saeed', 
    lastName: 'Neamati' 
} 

只需调用函数编写自己的函数中简单的JavaScript语句:

$("#id").click(function() { 
     appendLayout(this.id); 
     if(true){ alert("please create project"); } 
});