问题
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