asp.net中 gridview的生成table,标题行是<tr><th>title</th></tr>的格式。
现在想要在除标题行以外鼠标move过有变色效果。
这样是可以实现的。 $(document).ready(function()
    {
        var bgcolor;
        $('#GridView1 td').hover(function()
        {
            bgcolor=$(this).css('background-color');
            $(this).parent().css('background-color','#faa');
        },
        function()
        {
            $(this).parent().css('background-color',bgcolor);
        }
        );
    }
    );
但是$('#GridView1 tr').notcontains[th].hover(function()
为什么不行。
在jquery中如何排除tr以下的某个子元素啊??
应该怎么写?40分的传送门:http://topic.csdn.net/u/20100322/16/ecc3fca2-c3b3-4317-b866-0f84b9fe28c9.htmljs区人气太低了

解决方案 »

  1.   

    $(document).ready(function()
        {
            var bgcolor;
            $('#GridView1 tr').hover(function()
            {
                bgcolor=$(this).css('background-color');
                $(this).parent().css('background-color','#faa');
            },
            function()
            {
                $(this).parent().css('background-color',bgcolor);
            }
            );
        }
        );
      

  2.   

    你把标题行标记成<th>就可以了
      

  3.   

    我是这样写的,在datagrid的PreRender事件中添加如下代码
                if (Grid.Rows.Count > 0)
                {
                    //This replaces <td> with <th> and adds the scope attribute
                    .UseAccessibleHeader = true;                //This will add the <thead> and <tbody> elements
                    Grid.HeaderRow.TableSection = TableRowSection.TableHeader;                //This adds the <tfoot> element. 
                    //Remove if you don't have a footer row
                    Grid.FooterRow.TableSection = TableRowSection.TableFooter;
                }这样渲染出来的html代码包含<tbody>代码,jquery代码改成$('#GridView1 tbody td').hover(function()
      

  4.   

    if (Grid.Rows.Count > 0)
    {
    //This replaces <td> with <th> and adds the scope attribute
    Grid.UseAccessibleHeader = true;//This will add the <thead> and <tbody> elements
    Grid.HeaderRow.TableSection = TableRowSection.TableHeader;//This adds the <tfoot> element.
    //Remove if you don't have a footer row
    Grid.FooterRow.TableSection = TableRowSection.TableFooter;
    }
      

  5.   


    $('#<%= GridView1.ClientID%> tr:not(:has("th"))')
      

  6.   


    果然可以了。
    哈哈。
    那么多花真让人眼红啊。。
    2楼的:我的意思是th不让它变色。
    4楼的:后台代码我知道,但会增加服务器负担。
    js同样也可以。但现在在看jquer么,当然用jquer了。
      

  7.   

    up                                     sf