dimanche 24 juillet 2016

How to grab data from selected checkbox

I currently have a number of items each with a list of data inside. What I'm trying to achieve is, when i select a checkbox that has the same matching attribute of "itemName", the matching div that contains the additional data is appended to a container. I have written some code up here:

http://ift.tt/2anID7P

<div class="item" itemName="itemOne">
 <h2> Item One </h2>
 <ul>
  <li> Data 1 </li>
  <li> Data 2 </li>
  <li> Data 3 </li>
 </ul>
</div>

<div class="item" itemName="itemTwo">
 <h2> Item Two </h2>
 <ul>
  <li> Data 1 </li>
  <li> Data 2 </li>
  <li> Data 3 </li>
 </ul>
</div>

<ul class="itemSelection">
  <li itemName="itemOne"><label><input type="checkbox"/>Item One</label></li>
  <li itemName="itemTwo"><label><input type="checkbox"/>Item Two</label></li>
</ul>

<div id="container"></div>

Any help would be greatly appreciated.




Aucun commentaire:

Enregistrer un commentaire