2015-02-07 28 views
-1

我的要求是在點擊< -td->之後執行一些操作,之後用戶無法再次點擊< -td->。所以我可以停止相同的功能再次執行。但即使在此之後,我無法停止特定< -td->的點擊功能。無法停止表格上的點擊功能td

$(".ticktack tr td").click(function(e){ 

    e.preventDefault(); 
    e.stopPropagation(); 

    // some other code below 

} 

回答

4

您想在第一次點擊發生後刪除點擊處理程序。

$(".ticktack tr td").click(function(){ 
    // do something for first time 
    alert("test"); 

    // unbind the click handler for only this td 
    $(this).unbind('click'); 
} 
1

首先你要對<td>標籤像<td class='on-click'>現在你必須遵循下面的代碼

$(".ticktack tr td.on-click").click(function(e){ 
    $(this).removeClass("on-click"); 
}); 
0

添加類,你可以if語句與做並刪除其類時,其點擊一次

if($(".ticktack tr td").click){ 
alert("test"); 
$(".ticktack tr td").removeClass(".active") 
}