2013-12-20 35 views
2

我想要做的是當有人點擊表格中的一個url鏈接時停止切換。點擊鏈接時停止表格行切換

$(document).ready(function() { 
    $("#report tr:odd").addClass("odd"); 
    $("#report tr:not(.odd)").hide(); 
    $("#report tr:first-child").show(); 

    $("#report tr.odd").click(function() { 
     $(this).next("tr").toggle(); 
     $(this).find(".arrow").toggleClass("up"); 
    }); 
    //$("#report").jExpand(); 
}); 

URL鏈接就坐落在同一撥動行這當有人點擊該URL鏈接反過來,它也切換而我試圖阻止該行。如何做到這一點的任何指針?

+0

你可以發佈HTML – Bhadra

+0

請郵寄的東西是越來越切換HTML,你想獲得觸發什麼,你不想要切換,代碼本身沒有意義 –

回答

0

由於錨添加JavaScript函數調用中tr元素,每當上anchor點擊被調用時,該事件將被傳遞到父tr,也執行了點擊功能。

$('a').click(function(e){ 
    e.stopPropagation(); 
}); 

這將停止錨點擊泡沫事件到父

+1

非常感謝!它非常出色。 – user3122008

2

我覺得下面可能適合你。雖然沒有測試過。

在您的鏈接

$("#ANCHIOR_ID").click(function(event){ 
    event.stopPropagation(); 
    // then do your job there that you want to do in on click 
    });