HTML checkbox onclick called in Javascript

前端 未结 4 861
南方客
南方客 2020-12-09 01:32

I am having a bit of trouble trying to figure out how to get a certain part of my code to work.



        
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-09 02:23

    jQuery has a function that can do this:

    1. include the following script in your head:

      
      

      (or just download the jQuery.js file online and include it locally)

    2. use this script to toggle the check box when the input is clicked:

      var toggle = false;
      $("#INPUTNAMEHERE").click(function() {
              $("input[type=checkbox]").attr("checked",!toggle);
              toggle = !toggle;
      }); 
      

    That should do what you want if I understood what you were trying to do.

提交回复
热议问题