Get checkbox list values with jQuery

后端 未结 8 1861
抹茶落季
抹茶落季 2020-12-13 18:35

In a div, I have some checkbox. I\'d like when I push a button get all the name of all check box checked. Could you tell me how to do this ?

8条回答
  •  一生所求
    2020-12-13 18:39

    var aArray = [];
    window.$( "#myDiv" ).find( "input[type=checkbox][checked]" ).each( function()
    {
      aArray.push( this.name );
    
    });
    

    You can put it in a function and execute on click of the button.

提交回复
热议问题