I will put out the CSS style first. In fact, this can be ignored directly
body{margin:0;padding:0;font-size:12px;font-family:Microsoft Yahei;}
.datagrid{width:100%;}
.datagird tr th{background-color: #191970; font-size:14px;}
.datagrid tr th, .datagrid tr td{border:1px solid #ccc; border-collapse:collapse;}
/* Select row style*/
.table-row-selected{background:#fff68f;}
Let’s look at the page HTML structure
Implement the function
1) Click the row to change the background color
$ (".datagrid tbody tr").bind("click", function () {
var oThis = $(this);
if (oThis.hasClass("table-row-selected")) {
oThis.removeClass("table-row-selected");
oThis.children("td:eq(0)").children("input[name='check']").removeAttr("checked ");
} else {
oThis.addClass("table-row-selected");
oThis.children("td:eq(0)").children("input[name=' check']").attr("checked", "checked");
}
});
2) Select all/unselect all function (not completed, to be Continued)