//table表中点击行,选中的那一行颜色会变成浅蓝色(颜色可以自己设定) //其中sellerTable 为table的id, $("#sellerTable tbody tr").mousedown(function () { $("#sellerTable tr").each(function () { $(this).css("background-color", ""); }); $(this).css("background-color", "#98D8F5"); }); //前台绑定按钮事件(通过遍历table中的颜色,每行颜色和表头颜色比较,颜色不一样的那一行,就为选中的那一行) $("#btnDelete").click(function () { var sellerCD = ""; $('#sellerTable tr').each(function () { if ($(this).css("background-color") != $("th").css("background-color")) { sellerCD = $(this).find("td").eq(0).text();//令sellerCD为第一列的值 return false; } }); if (sellerCD == null || sellerCD == undefined || sellerCD == "") { alert("販売先情報を選択してください。"); } else { //页面跳转时传送数据,可以到SellersDetail页面中获取该数据如:sellerCD = Request.QueryString["sellerCD"]; window.location.href = "SellersDetail.aspx?type=delete&sellerCD=" + sellerCD; } })