2011-11-16 82 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"); } 
});