我想创建一个 jquery 函数,如果一个下拉值等于另一个类的值,它将被选中。
<input type="hidden" class="target" value="two people"></input>
<select id="source">
<option value="one person">One Person</option>
<option value="two people">Two People</option>
<option value="three people">Three People</option>
</select>
在上述情况下,选择了两个人。因为我使用迭代方法来生成选择,所以我无法将类应用于选项值。如果没有选项中的类,这可行吗?干杯。