如何检查是否单击了单选按钮?
$(document).ready(function() {
$("#rad").click(function() {
var radio = $("#rad input:checked");
if(radio == 0)
{
alert($(this).data('id'));
}
});
});
[html]
<input type="radio" data-id='1' name="default" class="rad" value="1">
<input type="radio" data-id='2' name="default" class="rad" value="1">
<input type="radio" data-id='3' name="default" class="rad" value="1">
<input type="radio" data-id='4' name="default" class="rad" value="1">
<input type="radio" data-id='5' name="default" class="rad" value="1">