当从上一个下拉列表中选择特定选项时,我正在尝试更改一组选择选项的文本。
这是我的html:
<select class="select" id="eventType" name="eventType" size="1">
<option value="0"></option>
<option value="wedding" name="wedding">Wedding</option>
<option value="private_party" name="private_party">Private Party</option>
<option value="corporate" name="corporate">Corporate Event</option>
</select>
<select class="select" id="band_type_choices" name="bandType">
<option value="0"></option>
<option value="acoustic" class="acoustic" name="acoustic">Acoustic</option>
<option value="jazz" class="jazz" name="jazz">Jazz/Easy Listening</option>
<option value="acoustic_jazz" class="acoustic_jazz" name="acoustic_jazz">Acoustic + Jazz/Easy Listening</option>
<option value="party" class="party" name="party">Party</option>
<option value="acoustic_party" class="acoustic_party" name="acoustic_party">Acoustic + Party</option>
<option value="jazz_party" class="jazz_party" name="jazz_party">Jazz/Easy Listening + Party</option>
<option value="acoustic_jazz_party" class="acoustic_jazz_party" name="acoustic_jazz_party">Acoustic + Jazz/Easy Listening + Party</option>
</select>
当有人从第一个下拉列表中选择“婚礼”时,我想更改所有 #band_type_choices 下拉列表的文本
这是我目前使用的 jQuery,但它什么也没做:
$('#eventType').change(function() {
var eventTypeName = $("#eventType option:selected");
if (eventTypeName.is(".wedding") ) {
$('#band_type_choices option:contains("acoustic")').text('Wedding Ceremony');
}
});