Py学习  »  Jquery

组合框交互中的jquery live方法

ronk • 5 年前 • 766 次点击  

我正试图在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相同

你有更好的主意吗 谢谢你

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/42901
 
766 次点击  
文章 [ 2 ]  |  最新文章 5 年前