jquery 赋值时不触发change事件解决——仙盟创梦IDE
一、传统方法jquey change
$('#village_id').trigger('change');$("#village_id").val('99');$("#village_id").change();
不生效
二、传统方法jquey
$('#village_id').trigger('change');
四、传统方法jquey
<input type="text" />
<button>赋值</button>
<script src="js/jquery.min.js"></script>
<script>$(function(){// 按钮点击事件$("button").on('click', function(){$("input").val("赋值成功");});// input值改变事件$("input").on('change', function(){$("button").after("<p>change事件触发</p>")});});
</script>
五、js 原生方法 new Event('change');
const 园区 = document.getElementById('village_id');
const event = new Event('change');
园区.dispatchEvent(event);
智能编程
智能编程能大幅提升编程效率,自动完成重复代码编写、精准提供代码建议,还可借助数据分析优化代码性能,并降低编程门槛,让更多人参与开发,加速创新进程
阿雪技术观
让我们积极投身于技术共享的浪潮中,不仅仅是作为受益者,更要成为贡献者。无论是分享自己的代码、撰写技术博客,还是参与开源项目的维护和改进,每一个小小的举动都可能成为推动技术进步的巨大力量
Embrace open source and sharing, witness the miracle of technological progress, and enjoy the happy times of humanity! Let's actively join the wave of technology sharing. Not only as beneficiaries, but also as contributors. Whether sharing our own code, writing technical blogs, or participating in the maintenance and improvement of open source projects, every small action may become a huge force driving technological progress.