<!--选择性别-->
<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“,却拿不到值
貌似本来就没有赋值,当然获取不到,判断一下是否checked不是一样嘛
你都没有给你的input赋值啊~加个value就行了
$("input[name='radio1']:checked").val(); 这个选择器是选择name='radio1'并且被选中的input输入框的值,而你所需要的男,女,是一个P标签里边的text。选择器错误。
weui有对应的js,github上有demo