如下的下拉框,其中非营业是被选中的(selected),使用Jsoup我怎么获取他的value值002?
<select id="tmainVo.car.useKindCode" name="tmainVo.car.useKindCode" class=" form-control " style="vertical-align:middle" originvalue=""><option value="">请选择</option><option selected value="002">非营业</option><option value="001">营业(非客车)</option><option value="003">出租、租赁</option><option value="004">城市公交</option><option value="005">公路客运</option></select>
同理还有复选框的情况,怎么选中那个被选中的(checked)那个的值?
<label style="line-height:15px;"> <input type="radio" name="tmainVo.car.carAttachNature" value="001" checked onchange="getUseNature();">个人 </label> <label style="line-height:15px;"> <input type="radio" name="tmainVo.car.carAttachNature" value="002" onchange="getUseNature();">企业 </label> <label style="line-height:15px;"> <input type="radio" name="tmainVo.car.carAttachNature" value="003"
Elements selects = element.getElementsByTag("select");
selects.forEach(sel ->{
Elements optins = sel.getElementsByTag("option");
optins.forEach(opt ->{
if(opt.hasAttr("selected")){
sel.attr("value",opt.attr("value"));
}
});
});
name value属性
jsoup用法和jquery差不多 不懂的就去研究jquery菜鸟教程