how can i get the value of radiobox in jquery
This question already has an answer here:
你应该得到按下复选框的值
var religion = $("input[name=religion]:checked").val();
alert(religion)
const radio1Value = document.querySelector("input").value;
console.log(radio1Value);
<input type="radio" name="religion" class="chk" name="religion" value="muslim">Muslim
<input type="radio" name="religion" class="chk" name="religion" value="christian">Christian
<input type="radio" name="religion" class="chk" name="religion" value="hindu">Hindu
try this
$(document).ready(function(){
$("input[type='button']").click(function(){
var radioValue = $("input[name='religion']:checked").val();
if(radioValue){
alert("Your are a - " + radioValue);
}
});
});
Demo
链接地址: http://www.djcxy.com/p/24590.html上一篇: jQuery获取所选单选按钮的值