如何连接单选按钮
<input type radio .. />
检查时调用函数?检查时我需要记录该按钮的值。
正如你在小提琴中看到的
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());
}
});
});
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')
{
}