“Periksa apakah tombol radio diperiksa” Kode Jawaban

Periksa apakah tombol radio diperiksa

$('#element').click(function() {
   if($('#radio_button').is(':checked')) { alert("it's checked"); }
});
Pan Dziad

Periksa tombol radio diperiksa jQuery

$(document).ready(function(){
  $('#submit_button').click(function() {
    if (!$("input[name='name']:checked").val()) {
       alert('Nothing is checked!');
        return false;
    }
    else {
      alert('One of the radio buttons is checked!');
    }
  });
});
Lokesh003Coding

JS Periksa apakah tombol radio diperiksa

if(document.getElementById('gender_Male').checked) {
  //Male radio button is checked
}else if(document.getElementById('gender_Female').checked) {
  //Female radio button is checked
}
Stupid Squirrel

Nilai tombol radio JavaScript jika diperiksa

//alert(document.querySelector('input[name = "comp"]:checked').value);

$test=document.querySelector('input[name = "comp"]:checked').value;

if($test="silver") {
        amount=50;
    }else if($test="gold") {
      amount=90;
    }else{
      amount=30;
    }
Mohamed Sami khiari

Periksa apakah salah satu tombol radio diperiksa


      if ($('input[name='+ radioName +']:checked').length) {
           // at least one of the radio buttons was checked
           return true; // allow whatever action would normally happen to continue
      }
      else {
           // no radio button was checked
           return false; // stop whatever action would normally happen
      }
    
syeddeveloper

Jawaban yang mirip dengan “Periksa apakah tombol radio diperiksa”

Pertanyaan yang mirip dengan “Periksa apakah tombol radio diperiksa”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya