如何连接radioButton
<input type radio .. />
检查时调用功能? 我需要在检查时记录该按钮的值。
答案 0 :(得分:2)
HTML:
<input type="radio" value="Test 1" /> Bullet 1 <br />
<input type="radio" value="Test 2" /> Bullet 2 <br />
<input type="radio" value="Test 3" /> Bullet 3 <br />
<input type="radio" value="Test 4" /> Bullet 4 <br />
JS:
$(document).ready(function() {
$("input").click(function() {
if ($(this + ":checked")) {
alert($(this).val());
}
});
});
答案 1 :(得分:1)
JS:
<script>
function yourfunction()
{
//function
}
</script>
<input id = "radio1" type = "radio" onclick = "yourfunction()" />
jQuery的:
<script>
$( '#radio1' ).click(function(e)
{
//function
});
</script>
<input id = "radio1" type = "radio" />
您可以添加条件以检查收音机是否被检查,看起来像是
if ($( '#radio' ).attr('checked') == 'true')
{
}