priya priya - 1 month ago 11
jQuery Question

how can i get the value of radiobox in jquery

how can i get the value of radiobox in jquery

<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


i have tried this, but i am not getting the value, how can i do this ?

var religion = $("name=religion").val();
alert(religion)

Answer

You should get value of pressed checkbox by

var religion = $("input[name=religion]:checked").val();
alert(religion)
Comments