【发布时间】:2025-12-30 03:55:12
【问题描述】:
我正在尝试在 Jquery 中做下一件事。 我有 2 个组合框,我想确保它们选择的值是相同的。如果用户在其中一个组合中选择一个值,就像另一个一样,我想提醒“无效操作”并将组合选择的值设置为其先前的值。 所以我写道:
$("#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
你有更好的想法/更短的建议吗 谢谢你
【问题讨论】:
-
我认为一些可接受的语法和拼写可以帮助你多一点。我们非常重视格式正确的问题。
-
4 个空格。 *.com/editing-help,但此处的常见问题解答不会告诉您句子以大写字母开头。
-
@Joseph Silvashy:并非世界上每个人都能说一口流利的英语。有些人在用外语表达他们想表达的东西时遇到问题。没有必要攻击。
-
还不错,但我不知道 leet speak 比英语更受欢迎。我想,如果我在一个以口语为主的社区寻求帮助,我会更重要。
-
@Joeseph Silvashy。从什么时候开始,“leet”出现在牛津词典中。吃自己的狗粮。
标签: jquery combobox live onchange