【发布时间】:2019-12-27 07:00:43
【问题描述】:
我有两个选择字段 - wpvcountry 和 wpvregion。
如果 wpvcountry 选择了选项 1(即值为 0),我想将 wpvregion 的选项 1 的标签替换为文本 请先选择一个国家
到目前为止,这是我的代码:
if ( $('select[name="wpvcountry"]').val() == 0 ) {
$('select[name="wpvregion"]').val(0).text('Please select a country first');
}
这目前只是覆盖所有选择选项,导致:
<select name="wpvregion" class="form-control">Please select a country first</select>
任何想法我做错了什么?
【问题讨论】:
标签: jquery