简体   繁体   English

如何使 jquery 网格 header 不可点击?

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

I have a gridview in jquery modal window.我在 jquery 模态 window 中有一个 gridview。 this grid displays different results depending upon the user selection on page.此网格根据页面上的用户选择显示不同的结果。 hence the div is populated at runtime with a dataset and colum headers.因此 div 在运行时使用数据集和列标题填充。

I am highlighting the clicked row as below我正在突出显示单击的行,如下所示

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

    });

and highlighting the hover as并将 hover 突出显示为

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

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

    });

But this makes the header row also clickable and hover also changes the style.但这使得 header 行也可点击,并且 hover 也改变了样式。 How can I make header row as non clickable?如何使 header 行不可点击?

Use the :not() and :first selectors:使用:not():first选择器:

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

Demo演示


EDIT: 编辑:
To make both header and footer rows unclickable, you can combine :not() with the :first and :last selectors: 要使 header 和页脚行都不可点击,您可以将:not():first:last选择器结合使用:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM