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.

相关推荐
天平9 小时前
油猴脚本创建webworker踩坑记录
前端·javascript·typescript
原则猫10 小时前
前端基础大厦
前端
陈随易11 小时前
编程语言级别的Skill市场,AI Agent 的未来形态
前端·后端·程序员
SoaringHeart12 小时前
Flutter进阶:基于 EasyRefresh 的下拉刷新封装 n_easy_refresh_mixin.dart
前端·flutter
IT_陈寒14 小时前
Vite的热更新突然不香了,排查三小时差点砸键盘
前端·人工智能·后端
子兮曰14 小时前
Agency-Agents 深度解析:400+ AI 专家的"梦之队"如何重塑开发工作流
前端·后端·vibecoding
山河木马15 小时前
渲染管线-计算得到gl_Position(顶点着色器)之后续GPU流程
javascript·webgl·图形学
竹林81815 小时前
用 The Graph 查询链上数据实战:从手搓 RPC 到 Subgraph,我的 NFT 项目数据加载快了 10 倍
前端·javascript
妙码生花15 小时前
从 PHP 到 AI + Golang,程序员自救转型手记(十九):点选验证码代码逐行目检
前端·后端·go
Awu122716 小时前
⚡从零开发 Agent CLI(五)实现一个可治理、可扩展的工具系统
前端·人工智能·claude