What’s wrong with this code? Why doesn’t it show value?
<script>
$(document).ready(function()
{
$('#radio_div').change(function(event){
var value = $("input[@name='rdio']:checked").val();
$('#update_text').html('Radio value:' + value);
});
});
</script>
</head>
<body>
<div id="radio_div">
<input type="radio" name="rdio" value="a" />
<input type="radio" name="rdio" value="b" />
<input type="radio" name="rdio" value="c" />
</div>
<div id="update_text">Please push radio button</div>
Because you’re binding to the change event of the radio_div div. A div does not fire a change event, only input elements do that..
Do this instead: