javascript - Getting values of hidden checkboxes jQuery -


i have form several checkboxes. values need true default have made them hidden as:

 <input type=checkbox name="<%= _key %>" checked="checked" style="display:none" /> 

to retrieve values i'm doing:

 var form_data = {}     $('form').find("input").each(function(i, e) {          if (e.checked)              form_data[e.name] = e.value;      }); 

but hidden input fields not coming. doing wrong? how can correct it?

also im using underscore.js don't think problem has it.

for simplicity can this:

$(function(){ // put code in doc ready    var form_data = {}       $('form').find(":checkbox:checked").each(function(i, e) {         form_data[e.name] = e.value;     }); }); 

so here suggesting loop through checked elems , put names & values in javascript object.


but if interested in hidden checked checkboxes $('form').find(":checkbox:checked:hidden").


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -