How do i check a radio button is checked or not using jquery???
here is the code:
function handlesClick(myRadio) {
debugger
var selectedmerchant = [];
if (myRadio != '') {
var myRadios = $('input[name=myRadio]');
//var checkedValue = $("#myRadio").attr('checked', 'checked');
//if ($('#myRadio').is(':checked')) { alert("it's checked"); }
//$('input[type="radio"][class="icheck-list"]:checked').val()
if ($("#myRadio").is(":checked") === true)
{
selectedmerchant.push(myradio);
selectedmerchant.join(",");
}
else
{
var index = selectedmerchant.indexof(merchant);
selectedmerchant.splice(index, 1);
}
//if (document.getelementbyid(myradio).checked == true) {
// selectedmerchant.push(myradio);
// selectedmerchant.join(",");
//}
//else {
// var index = selectedmerchant.indexof(merchant);
// selectedmerchant.splice(index, 1);
//}
i want to check is the checkbox is checked or not so that i can push or slice in a array using javascript. any code???
here is the html:
<div class="row">
<div class="form-group">
<div class="col-md-12">
<label>3.sdfdsfsdfds</label>
<div class="icheck-list">
<label class="icheck-list" id="11">
<input name="3" onclick="handlesClick(this);" id="3_11" type="radio">Strongly Disagree
<span></span>
</label>
</div>
<div class="icheck-list">
<label class="icheck-list" id="12">
<input name="3" onclick="handlesClick(this);" id="3_12" type="radio">Disagree
<span></span>
</label>
</div>
<div class="icheck-list">
<label class="icheck-list" id="13">
<input name="3" onclick="handlesClick(this);" id="3_13" type="radio">Neither Agree or Disagree
<span></span>
</label>
</div>
<div class="icheck-list">
<label class="icheck-list" id="14">
<input name="3" onclick="handlesClick(this);" id="3_14" type="radio">Agree
<span></span>
</label>
</div>
<div class="icheck-list">
<label class="icheck-list" id="15">
<input name="3" onclick="handlesClick(this);" id="3_15" type="radio">Strongly Agree
<span></span>
</label>
</div>
</div>
</div>
</div>