asp.net listview highlight row on click

守給你的承諾、 提交于 2019-12-02 16:10:03

问题


I know how to set up listview to highlight a row when you click a link, image, etc but I am just wondering if it is possible to set it up to highlight a row when you click on any of its cells, not just on a predefined control.

Is that possible?

I way around it would be to setup onclick of each <td> but no idea how to reset the background colour when you click on another cell.


回答1:


You could use Jquery on the client side:

$("#myTable tr").click( function () 
{
   $("#myTable tr").each(function () { $(this).removeClass("selected")}); 
   $(this).addClass("selected"); 
});​

An example fiddle:

http://jsfiddle.net/9pmcA/26/



来源:https://stackoverflow.com/questions/11052761/asp-net-listview-highlight-row-on-click

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!