jQuery事件对输入值的更改隐藏 [英] jQuery event on value change of input hidden
本文介绍了jQuery事件对输入值的更改隐藏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我隐藏了此输入:
<input id="j_idt26:myValue" type="hidden" name="j_idt26:myValue" value="0?100?">
我想在第一次设置该值时提醒嘿",然后在每次更改时提醒.
I want to alert "hey" the first time the value is set and then every time it changes.
我有这样的东西:
$(document).ready(function(){
var $hello= $('[id$=myValue]');
$hello.bind("change load", function(){
alert('hey');
});
});
但是什么都没有出现.
如果可以帮助
谢谢
But nothing is showing up.
If you can help
Thanks
推荐答案
$(function(){
var $hello= $('[id$="myValue"]');
$hello.on("change", function(){ //bind() for older jquery version
alert('hey');
}).triggerHandler('change'); //could be change() or trigger('change')
});
然后,每次您更改目标隐藏输入的值时,都会触发触发器处理程序,例如:
Then, each time you change the value of targeted hidden inputs, trigger handler, e.g:
$('#j_idt26:myValue').val('0?200?').triggerHandler('change');
这是因为onchange事件不会自动以编程方式更改其值而触发.
That's because onchange event is not fired automatically changing its value programatically.
这篇关于jQuery事件对输入值的更改隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文