asp.net listview highlight row on click

2019-03-03 14:19发布

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条回答
啃猪蹄的小仙女
2楼-- · 2019-03-03 14:51

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/

查看更多
登录 后发表回答