dimanche 19 avril 2020

Get the text of all the checked checkboxes using jquery [duplicate]

I have a input checkboxes in listitems and i need to fetch the selected checkbox text.Below is my html code and i had differentiated the unchecked checkbox with the checked checkbox

<li tabindex="-1" role="option" unselectable="on" class="k-item">//unchecked check box
     <input type="checkbox" name="Type" onclick="Check(event);" class="cbComp" value="40532"> Unselected check box
</li> 

 <li tabindex="-1" role="option" unselectable="on" class="k-item k-state-selected k-state-focused" id="ddlActTypeCompletedKD_option_selected" aria-selected="true">  //checked chekbox
     <input type="checkbox" name="cbCareActType" onclick="onCareActCompletedCheck(event);" 
     class="cbCareActTypeComp" value="40549">Checked checkbox1
 </li>
 <li tabindex="-1" role="option" unselectable="on" class="k-item k-state-selected k-state-focused" id="ddlActTypeCompletedKD_option_selected" aria-selected="true">  //checked chekbox
     <input type="checkbox" name="cbCareActType" onclick="onCareActCompletedCheck(event);" 
     class="cbCareActTypeComp" value="50890">Checked checkbox2
 </li>

Using below code I am getting all the checked checkboxes values in comma separated, but I need to bring the text.

How can I do this?

Text = $('#AddActTypeCompletedhdn').val();

//I am getting values as 40549,50890 as those both are checked using these values i need to get text

Input will be the values in the hidden field Example -40549,50890 Output should be the text of those values to be displayed as comma seperated in dropdown Expected output- Checked checkbox1,Checked checkbox2




Aucun commentaire:

Enregistrer un commentaire