javascript - fetch multiple checked values from ul li in jquery -


i have included given code

<ul class="checkboxes">   <li class=" ">     <label title="" for="option-0">       <input type="checkbox" aria-selected="true" title="" value="all" name="country" id="option-0"><i>all</i>     </label>   </li>   <li class=" ">     <label title="" for="option-1">       <input type="checkbox" title="" value="1" name="country" id="option-1" aria-selected="true"><i>test</i>     </label>   </li>   <li class=" ">     <label  title="" for="option-2">       <input type="checkbox" title="" value="2" name="country" id="option-2" aria-selected="true"><i>abcd</i>     </label>   </li>   <li class=" ">     <label  title="" for="option-3">       <input type="checkbox" title="" value="3" name="country" id="option-3" aria-selected="true"><i>loreum</i>     </label>   </li>   <li class=" ">     <label  title="" for="option-4">       <input type="checkbox" title="" value="4" name="country" id="option-4" aria-selected="true"><i>ipsum</i>     </label>   </li> </ul> 

i want fetch checked values list eg: if have have selected ipsum loreum , test how fetch these texts through jquery. please me out. in advance

you can use .map() function on checked elements return array of text sibling element:

$('ul input:checked').map(function(){    return $(this).next('i').text(); }).get(); 

working demo


Comments