jQuery   发布时间:2022-04-19  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了jquery – 是否有可能找到触发了.change()的值?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
来自< select>标签,是否可以找到.change()被触发的值?

解决方法

使用变量缓存先前的值.

// bind change event handler to the eleemnt 
// and cache the current value in `prev`
var prev = $('#test').change(function() {
  // get prevIoUs value from `prev`
  console.log('prev : ' + prev + ',current : ' + this.value);

  //... do the rest here

  // update the `prev` variable with current value
  prev = this.value;
}).val(); // get the default value
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select id="test">
  <option value="1">1</option>
  <option value="11">11</option>
  <option value="111">111</option>
</select>

大佬总结

以上是大佬教程为你收集整理的jquery – 是否有可能找到触发了.change()的值?全部内容,希望文章能够帮你解决jquery – 是否有可能找到触发了.change()的值?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: