I want to get the value of selected radio button.
When no radio is selected it shows undefined correctly. However, when i click on any radio button also it shows undefined.
How can i do this in either javascript or jquery.
HTML code:
<div id="rates">
<input type="radio" class="demo" id="r1" name="rate" value="Fixed Rate"> Fixed Rate
<input type="radio" class= "demo"id="r2" name="rate" value="Variable Rate"> Variable Rate
<input type="radio" class="demo" id="r3" name="rate" value="Multi Rate"> Multi Rate
</div>
JS:
console.log($('.demo:selected').val());
Fiddle: http://jsfiddle.net/eLJ4s/1/