Click table rows to select checkbox using jQuery

前端 未结 5 1617
难免孤独
难免孤独 2020-12-01 03:07

As I didn\'t find any question asked before, on how to toggle checkbox on click of a table row, so I would like to share my approach to this...

5条回答
  •  一整个雨季
    2020-12-01 03:37

    You may simply trigger this click event...:)

      $(document).ready(function()
        {
          $("table tr th :checkbox").click(function(event)
          {
            $('tbody :checkbox').trigger('click');
          });
        });
    

    OR

      $(document).ready(function()
        {
          $("table tr th :checkbox").on('click',function(event)
          {
            $('tbody :checkbox').trigger('click');
          });
        });
    

提交回复
热议问题