社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Jquery

组合框交互中的jquery live方法

ronk • 5 年前 • 763 次点击  

我正试图在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
 
763 次点击  
文章 [ 2 ]  |  最新文章 5 年前