【问题标题】:asp.net listview select onmouseoverasp.net listview 选择鼠标悬停
【发布时间】:2012-06-15 22:10:33
【问题描述】:

当您将鼠标悬停在列表视图上时,如何突出显示整行? 例如,如果您将鼠标悬停在一行上,则该行的背景颜色会发生变化。 我假设它是 tr 的 onmouseover 属性?

【问题讨论】:

    标签: c# asp.net


    【解决方案1】:

    如果你习惯使用,jQuery 试试这个:

    $(function(){
    $("tr").hover(function(){
        $(this).css('background-color', '#FFFF99');;
        $(this).css('background-color', '#FFFFFF');;
        });
    });
    

    更新:

    给你的“tr”标签添加一个类 例如:

    <tr class="trOnHoverChange"></tr>
    
    $(function(){
    $(".trOnHoverChange").hover(function(){
        $(this).css('background-color', '#FFFF99');;
        $(this).css('background-color', '#FFFFFF');;
        });
    });
    

    【讨论】:

    • 这也很好用:onmouseover="this.style.background='Red';" onmouseout="this.style.background='#222222'" 如果应用于 ItemTemplate tr 和 AlternatingItemTemplate
    【解决方案2】:

    我发现这与您的问题相似,可能会为您指明正确的方向:

    ASP.NET Gridview: Highlighting rows on mouse over then updating the highlighted rows

    编辑

    刚找到这个,听起来像你现在正在做的事情。

    http://forums.asp.net/t/1450332.aspx

    【讨论】:

    • 不完全是,listview 的工作方式与 gridview 完全不同。我知道gridview要容易得多,但我需要使用高级格式,因此是使用listview的原因。我相信我可能拥有它,它可能只是设置背景颜色 onmouseover 然后 onmouseout 的问题
    • 很公平,我曾经做过类似的事情,但它是很久以前的,所以我不记得了。
    猜你喜欢
    • 2011-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-04
    • 2018-09-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多