jQuery - Detect value change on hidden input field
You can simply use the below function, You can also change the type element.
$("input[type=hidden]").bind("change", function() {
alert($(this).val());
});
Changes in value to hidden elements don't automatically fire the .change() event. So, wherever it is that you're setting that value, you also have to tell jQuery to trigger it. HTML
<div id="message"></div>
<input type="hidden" id="testChange" value="" />
JAVASCRIPT
var $message = $('#message');
var $testChange = $('#testChange');
var i = ;
function updateChange() {
$message.html($message.html() + '<p>Changed to ' + $testChange.val() + '</p>');
}
$testChange.on('change', updateChange);
setInterval(function() {
$testChange.val(++i).trigger('change');;
console.log("value changed" +$testChange.val());
}, );
updateChange();
should work as expected.
转载:http://stackoverflow.com/questions/6533087/jquery-detect-value-change-on-hidden-input-field
jQuery - Detect value change on hidden input field的更多相关文章
- JQuery Checkbox的change事件
JQuery Checkbox的change事件 参考 http://blog.csdn.net/hbhgjiangkun/article/details/8126981 $(functio ...
- jQuery的事件change
人生还在继续,只有不断补充以前所不懂的知识,今天练习一个jQuery的事件change.这个事件是在对象失去focus并且原本值有所变化时就产生此事件.如select时,用户所选择的选项有变时,或是t ...
- unity, ugui input field
ugui Input Field,获取输入的字符串. 错误方法: string content=inputField.FindChild("Text").text; 这样得到的是输 ...
- 原生js在IE7下 向dom添加节点的一个bug, (本例为添加hidden input)
需求是要用js向dom结构增加1个hidden用来存放要post到服务器的数据 var aspnetForm = document.getElementById("aspnetForm&qu ...
- change事件和input事件的区别
input事件: input事件在输入框输入的时候回实时响应并触发 change事件: change事件在input失去焦点才会考虑触发,它的缺点是无法实时响应.与blur事件有着相似的功能,但与bl ...
- jquery监听动态添加的input的change事件
使用下面方法在监听普通的input的change事件正常 $('#pp').on('change', 'input.videos_poster_input', function () { consol ...
- [Infopath]使用jquery给infopath表单的的field赋值。 how to set value to Infopath field by Jquery
客户有个需求,需要在infopath表单中嵌入一段我们自己的东西,计算后要更新infopath某一个field. 1. 怎么去获取到那个field 由于infopath生产的html非常的复杂,嵌套太 ...
- jQuery还原select下拉列表和清空input的值,回显下拉列表框的值
实现用jQuery还原select下拉列表的值,用了很多种方式,花了一些时间,最后重要找到一种可以实现的方式, 页面上有这些内容 <select id ="level" na ...
- Jquery操作select,radio,input,p之类
select的操作 变化后触发操作 $("#txtaddprojecturl").change(function(){ $("#addprojectname") ...
随机推荐
- 上海市2019年公务员录用考试第一轮首批面试名单(B类)
上海市2019年公务员录用考试第一轮首批面试名单(B类) 2019-03-12 设置字体:大 中 小 职位序号 注册编号 职位序号 注册编号 职位序号 注册编号 职位序号 注册编号 1910565 5 ...
- ServletContextListener使用详解(监听Tomcat启动、关闭)
在 Servlet API 中有一个 ServletContextListener 接口,它能够监听 ServletContext 对象的生命周期,实际上就是监听 Web 应用的生命周期. 当Serv ...
- XamarinAndroid组件教程设置自定义子元素动画(二)
XamarinAndroid组件教程设置自定义子元素动画(二) (9)打开MainActivity.cs文件,为RecylerView的子元素设置添加和删除时的透明动画效果.代码如下: …… usin ...
- bootstrap图片轮播
<div class="carousel slide" id="myCarsousel" style="width:790px;"&g ...
- Hibernate中Restrictions查询用法(转)
Restrictions查询用法 HQL运算符 QBC运算符 含义 = Restrictions.eq() 等于equal <> Restrictions.ne() 不等于not equa ...
- 英语口语练习系列-C33-露营-谈论日期-离思
词汇-露营 Camping camping 露营 campground camping camper picnic bonfire backpack tent public campground co ...
- [蓝点ZigBee] Zstack 之按键驱动以及控制LED灯 ZigBee/CC2530 视频资料
这一节主要演示如何在Zstack 下根据板子的不同修改按键驱动,实际演示的时候代码跳动比较多,建议大家除了看视频资料以外,还需要在网上找一下相关资料进一步学习. 视频总览:http://bphero. ...
- tornado websocket聊天室
1.app.py #!/usr/bin/env python # -*- coding:utf-8 -*- import uuid import json import tornado.ioloop ...
- Python爱好者社区历史文章列表(每周append更新一次)
2月22日更新: 0.Python从零开始系列连载: Python从零开始系列连载(1)——安装环境 Python从零开始系列连载(2)——jupyter的常用操作 Python从零开始系列连载( ...
- JavaScript中date 对象常用方法
Date 对象 Date 对象用于处理日期和时间. //创建 Date 对象的语法: var datetime = new Date();//Date 对象会自动把当前日期和时间保存为其初始值. co ...