javascript - Displaying checkbox data when clicked -


i'm trying make multiple select checkbox ... if click checkbox checkbox b follow click too. checkbox appears, b checkbox created in hidden state css ..

<button type="button" id="delete" title="delete">delete</button>  <input type="checkbox" class="select_data"  id="a" name="a[]" value="a" /> <input type="checkbox" class="info_del" id="b" name="b[]" value="b">  $('#delete').click(function() {         if($('#a').is(":checked")) {             $('#b').attr('checked', true).val();          }      var data = $(".select_data:checked, .info_del:checked").serialize();     console.log(data);        }); 

i believe have syntax issue 1 line of jquery.

try changing line:

$('#b').attr('checked', true).val(); 

to:

$('#b').prop('checked', true); 

here working pen.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -