mardi 5 septembre 2017

How to get label values of checkbox in javascript

I have two checkbox, depending upon,which checkbox user clicks, I need to call other function, however, I'm not abler to get the check box label values, here is my code

function getLabel(id)
{
  return $("#"+id).next().text();
}
function BillStatus(){
  console.log("its here");
  var label=getLabel('checkboxid1'); 
  console.log(label);
  if(label=="No") {
//some function to call here

}else{
  //other function to call here
}
}
<script src="http://ift.tt/1oMJErh"></script>
<div id="check1">
  <label>
    <input type="checkbox" name="myCheckbox" id="checkboxid1" onclick="BillStatus()" style="visibility: visible"
           /> Yes</label>
</div>
<br>
<div id="check2">
  <label>
    <input type="checkbox" id="checkboxid2" name="myCheckbox" value="No" onclick="BillStatus()" style="visibility: visible" />No</label>
</div>



Aucun commentaire:

Enregistrer un commentaire