更新时间:2022-12-18 13:01:14
尝试一下:
<form id="switch" method="POST">
<table>
<tr>
<td><label>some content<input type="radio" name="switch_value" value="1"></label></td>
<td><label>some content<input type="radio" name="switch_value" value="2"></label></td>
<td><label>some content<input type="radio" name="switch_value" value="3"></label></td>
<td><label>some content<input type="radio" name="switch_value" value="4"></label></td>
<td><label>some content<input type="radio" name="switch_value" value="5"></label></td>
</tr>
</table>
</form>
<script>
$(document).ready(function(){
$('#switch input[type="radio"]').change(function(){
$('#switch').submit();
});
});
</script>
我以这种方式在label
之间包裹了文本和单选按钮,即使您使用CSS隐藏radio buttons
,文本也会将事件传播到单选按钮.
I wrapped the text and the radio buttons between label
that way, even if you use css to hide the radio buttons
, the text would propagate the event down to the radio button.