对于多个选择表单,如何表达选择的多个选项?
<select name="sweets" multiple="multiple">
<option>Chocolate</option>
<option selected="selected">Candy</option>
<option>Taffy</option>
<option selected="selected">Caramel</option>
<option>Fudge</option>
<option>Cookie</option>
</select>
/html/body/form/select/option[1],option[2],option[3]
?
答案 0 :(得分:2)
试试这个:
/html/body/form/select/option[1] | /html/body/form/select/option[2]
管道符(“|”)连接两组,删除重复的
答案 1 :(得分:1)
或许更喜欢“/ html / body / form / select / option [@ selected ='selected']”
答案 2 :(得分:1)
未经测试,但不会是:
/html/body/form/select/option[@selected='selected']
更新:根据您的评论,您不需要像:
/html/body/form/select/option[@val = '1' or @val = '3']
(尽管您的示例选择没有任何val
属性)