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") ...
随机推荐
- spring_AOP_annotation
例子下载 beans.xml 首先,在配置文件配置好下面的配置 <?xml version="1.0" encoding="UTF-8"?> < ...
- PHP Kohana入门体验教程
打开入口文件kohana目录下的index.php, 左边选中的文件和右边选中的是对应,如果重命名的话两边都要修改. 设置程序默认时区D:\xampp\htdocs\kohana\applicatio ...
- jsoup 解析html
http://www.cnblogs.com/jycboy/p/jsoupdoc.html http://www.cnblogs.com/mokafamily/p/3558620.html
- 如何绘制UML图?
首先推荐在线绘制UML的网址:https://www.processon.com/,很好用. 在软件开发过程中,开发人员往往需要通过绘制类图来理清业务的实现思路,从而方便代码实现,也便于后期的代码维护 ...
- app的创建和注册
APP是用来存放代码的 创建APP 命令行创建,切换到项目目录下 python manage.py startapp appo1 #app01为项目名,创建完刷新即可 目录结构 把函数放到views后 ...
- day6常用模块,数据库操作
一.循环调用函数 map() 二.列表推导式和生成器 三.filter过滤器 四.os模块 五.datetime模块 六.random模块 七.写日志,导入nnlog模块 八,发邮件 九,操作数 ...
- 11-8 定时器this
定时器this问题 var t=setInterval(function(){ console.log(this) },1000) 这里面的this是window Person.prototype={ ...
- react-navigation 中的多tabs嵌套时内部tabs无法正常切换问题
原因 问题应该是当用户滑动或切换时,无法判断是哪个tabs应该进行滑动切换和展示切换动画. 解决 swipeEnabled - 是否允许在标签之间进行滑动 animationEnabled - 是否在 ...
- 记录下pytorch代码从0.3版本迁移到0.4版本要做的一些更改。
1. UserWarning: Implicit dimension choice for log_softmax has been deprecated. Change the call to in ...
- 移动端适配问题px->rem方法
移动端web页面适配问题 1.引入插件 github地址:https://github.com/re54k/mobileweb-utilities/blob/master/util/mobile-ut ...