mardi 18 août 2020

How to get date from checkbox and div class to array

I clicked on checkbox and I want it to be shown next to the div with class that suits the id from checkbox on the array.

I tried to do it with the code but something is not working.

   

 $('button').on('click', function() {
  var array = [];
  array1.push($(this).text());

  $("input:checked").each(function() {
    array.push($(this).val());
    $('#myModalLink').modal('hide');
  });

  $('#oto').each(function() {
    array1.push($(this).text());

  });

  $('#test').text(array);
  $('#test').text(array1);
});
   

 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<td><input type="checkbox" value="20" /></td>
<td>
  <div id="oto">name</div>
</td>
<td>
  <div id="lng">lng</div>
</td>

 <td><input type="checkbox" value="16" /></td>
<td>
 <div id="oto">name1</div>
</td>
<td>
 <div id="lng">lng1</div>
</td>



Aucun commentaire:

Enregistrer un commentaire