DEV Community

bhagvan kommadi
bhagvan kommadi

Posted on

Javascript to check all and uncheck all

I found this script to check all the boxes and uncheck all the boxes by capturing the event of checking and unchecking by finding the state of the check box.

$('button[id="dataview"]').on('click', function(event){
alert(event.target.id);

            alert(event.target.name);

            text = event.target.name;

         if (event.target.checked == true){
              alert("checked")
              selects(text)
            } else {
              deSelect(text)
            }

          });
    $('button[id="analysis"]').on('click', function(event){
            alert(event.target.id);

            alert(event.target.name);

            text = event.target.name;



         if (event.target.checked == true){
              alert("checked")
              selects(text)
            } else {
              deSelect(text)
            }

          });
Enter fullscreen mode Exit fullscreen mode

Top comments (0)