我正在使用此代码:http: //jsfiddle.net/q3nUS/
$('#cf11_field_20').change(function() {
$("#li-11-22")[$(this).val() == "full03_accommodation_hotel" ? 'show' : 'hide']("fast");
}).change();
$('#cf11_field_22').change(function() {
$("#li-11-23")[$(this).val() == "full03_hotel_other" ? 'show' : 'hide']("fast");
}).change();
它工作正常,因此文本字段仅在以下情况下出现:在第一个下拉列表中选择“酒店”并且在第二个下拉列表中选择“其他”。
但是,一旦您将第一个下拉列表更改为“酒店”以外的内容,我显然需要隐藏其他两个字段。目前,文本字段仍然存在。
如何更改文本字段也被隐藏的代码?我知道如何在逻辑上做到这一点,但我遇到了语法问题。
我试过这样的事情:
$('#cf11_field_20').change(function() {
$("#li-11-22")[$(this).val() == "full03_accommodation_hotel" ? 'show' : 'hide']("fast");
$("#li-11-23")[$(this).val() != "full03_accommodation_hotel" ? 'hide']("fast");
}).change();
$('#cf11_field_22').change(function() {
$("#li-11-23")[$(this).val() == "full03_hotel_other" ? 'show' : 'hide']("fast");
}).change();
这里确实存在正确语法的问题。谢谢!