我正试图在jquery中做下一件事。
我有两个组合框,我想确保它们的选择值是相同的。如果用户在一个组合框中选择一个值,就像在另一个组合框中一样,我想提醒“无效操作”,并将组合框选择的值设置为其上一个值。
所以我写道:
$("#SelectGroupMargin").live("onchange", function() {
// save the value before the change in case the change is invalid
var valBeforeChange = $("#SelectGroupMargin").val();
var currentLimitedRuleVal = $("#SelectGroup").val();
var newFillerRule= $(this).val();
// check that the new value does not colide with the value of the limited rule
// if it does colide alert the user and return to the former value
if (currentLimitedRuleVal == newFillerRule) {
alert("invalid op");
$("#SelectGroupMargin").text(valBeforeChange);
}
});
但我没有什么问题:
1)onchange没有响应-只需单击并聚焦
2)NewFillerRule始终与ValbeforeChange相同
你有更好的主意吗
谢谢你