簡體   English   中英

如何使 jquery 網格 header 不可點擊?

[英]how to make jquery grid header non clickable?

我在 jquery 模態 window 中有一個 gridview。 此網格根據頁面上的用戶選擇顯示不同的結果。 因此 div 在運行時使用數據集和列標題填充。

我正在突出顯示單擊的行,如下所示

$('#imyGrid tr').click(function() {
        $('#<%=myGrid.ClientID%> tr').removeClass("selected");
        $(this).addClass("selected");

    });

並將 hover 突出顯示為

$('#<%=myGrid.ClientID%> tr').mouseover(function() {
    $(this).addClass("highlight");
    });

    $('#<%=myGrid.ClientID%> tr').mouseout(function() {
    $(this).removeClass("highlight");

    });

但這使得 header 行也可點擊,並且 hover 也改變了樣式。 如何使 header 行不可點擊?

使用:not():first選擇器:

$('#<%=myGrid.ClientID%> tr:not(:first)')

演示


編輯:
要使 header 和頁腳行都不可點擊,您可以將:not():first:last選擇器結合使用:

$('#<%=myGrid.ClientID%> tr:not(:first,:last)')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM