jquery - How to check status of Django generated multiple checkbox? -


i know how use jquery save names of selected options django based multiple checkbox? seems not able select group of checkbox... can give me suggestions on code? thanks!

jsfiddle example

html code

<table class="tab_model">     <tbody>         <tr>             <th>                 <label for="id_model_0">model:</label>             </th>             <td>                 <ul>                     <li>                         <label for="id_model_0">                             <input type="checkbox" name="model" value="a" id="id_model_0">model a</label>                     </li>                     <li>                         <label for="id_model_1">                             <input type="checkbox" name="model" value="b" id="id_model_1">model b</label>                     </li>                     <li>                         <label for="id_model_2">                             <input type="checkbox" name="model" value="c" id="id_model_2">model c</label>                     </li>                 </ul>             </td>         </tr>     </tbody> </table> <input class="submit" type="submit" value="submit"> 

jquery

var allvals = [];  $('.submit').click(function () {     $('input[id^="id_model_"] :checked').each(function () {         allvals.push($(this).val());     });     alert(allvals); }); 

i give boxes class, class='the_checkboxes' use:

$(".the_checkboxes:checkbox:checked").each(function()({     allvals.push($(this).val()); }); 

it cleaner (to me, anyway).


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -