现在,我将第一个下拉框的值更改为6月,但不会更改第二个下拉框,因为我已经使用boxes.One event.Here启动了第二个下拉框,因此无法通过第二个下拉框。我使用live(单击),但在没有单击第二个下拉框的情况下,该值也应该通过吗
**Updated**
$(firstselect).live(click,function)
$(secondselect).live(click,function)发布于 2011-06-30 17:45:14
现在我理解了问题所在:
第二个选择框应显示先前在第一个选择框中选择的值。
你可以这样做:
var prevValue = $('#firstselect').val();
$('#firstselect').change(function() {
$('#secondselect').val(prevValue);
prevValue = this.value;
});双向:
var prevValue = {
'firstselect': $('#firstselect').val(),
'secondselect': $('#secondselect').val()
};
$('select').change(function() {
var other = this.id === 'firstselect' ? 'secondselect' : 'firstselect';
prevValue[other] = $('#' + other).val();
$('#' + other).val(prevValue[this.id]);
prevValue[this.id] = this.value;
});https://stackoverflow.com/questions/6532359
复制相似问题