<!--选择性别-->
<p class="weui_cells weui_cells_radio">
<label class="weui_cell weui_check_label" for="x11">
<p id="man" class="weui_cell_bd weui_cell_primary">
<p>男</p>
</p>
<p class="weui_cell_ft">
<input type="radio" class="weui_check" name="radio1" id="x11">
<span class="weui_icon_checked"></span>
</p>
</label>
<label class="weui_cell weui_check_label" for="x12">
<p id="woman" class="weui_cell_bd weui_cell_primary">
<p>女</p>
</p>
<p class="weui_cell_ft">
<input type="radio" name="radio1" class="weui_check" id="x12" checked="checked">
<span class="weui_icon_checked"></span>
</p>
</label>
</p>
我要获取”男“或”女“,可是怎么都获取不到,怎么获取?
var doctorSex = $("input[name='radio1']:checked").val(); 只能获取个开关”on“,却拿不到值
PHP中文网2017-04-11 11:13:43
你都没有给你的input赋值啊~加个value就行了
<input type="radio" class="weui_check" name="radio1" id="x11" value="male">
<input type="radio" name="radio1" class="weui_check" id="x12" value="female" checked="checked">
大家讲道理2017-04-11 11:13:43
$("input[name='radio1']:checked").val(); 这个选择器是选择name='radio1'并且被选中的input输入框的值,而你所需要的男,女,是一个P标签里边的text。选择器错误。
<input type="radio" name="radio1" class="weui_check" id="x12" checked="checked" value='男'>
<input type="radio" class="weui_check" name="radio1" id="x11" value='女'>