I have a table
Food Name: Restaurant Name: 5条回答 萌比男神i (楼主) 2021-01-31 19:14 If you want only 1 row in the table to be selected at a time $("#data tr").click(function() { var selected = $(this).hasClass("highlight"); $("#data tr").removeClass("highlight"); if(!selected) $(this).addClass("highlight"); 0 讨论(0) 查看其它5个回答 发布评论: 提交评论 加载中... 验证码 看不清? 提交回复 热议问题
If you want only 1 row in the table to be selected at a time
$("#data tr").click(function() { var selected = $(this).hasClass("highlight"); $("#data tr").removeClass("highlight"); if(!selected) $(this).addClass("highlight");