-3
如何檢查一個單選按鈕被選中或者不使用jquery ???如何檢查一個單選按鈕被選中或者不使用jquery
這裏是代碼:
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);
//}
我要檢查的複選框被選中與否,這樣我可以使用JavaScript一個數組中推或切片。 任何代碼?
下面是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>
不工作這就是爲什麼我問的人 – Manoj
顯示一些相關的HTML – rahulsm
這可能意味着你的代碼沒有正確調用 –