jQuery implements the method of selecting or canceling CheckBox by clicking on the line

  • 2021-07-07 06:09:30
  • OfStack

In this paper, an example is given to describe the method of jQuery to select or cancel CheckBox by clicking on the line. Share it for your reference, as follows:

/// <summary>
///  Click on the line to select or cancel CheckBox
/// </summary>
/// <param name="TableID"> Table ID</param>
function SetCheckBox_Check(TableID) {
  var $TableID = TableID == "" ? "#tb_List" : "#" + TableID + "";
  // Loop each tr Row, add click Events 
  $($TableID).find("tr").live("click", function () {
    // The header row does nothing 
    if (this.rowIndex == 0) return;
    if ($(this).find("input").attr("checked") == 'checked') {
      // Uncheck the selected rows 
      $(this).find("input").attr("checked", false);
    } else {
      // If the row is not selected, select it 
      $(this).find("input").attr("checked", true);

More readers interested in jQuery can check the topics of this site: "Summary of jQuery Form (table) Operation Skills", "Summary of jQuery form Operation Skills", "Summary of jQuery Common Plug-ins and Usage", "Summary of jQuery Operation json Data Skills", "Summary of jQuery Extension Skills", "Summary of jQuery Drag Effects and Skills", "Summary of Ajax Usage in jquery", "Summary of jQuery Common Classic Special Effects", "Summary of jQuery Animation and Special Effects Usage" and "Summary of jquery Selector Usage"

I hope this article is helpful to everyone's jQuery programming.

Related articles: