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
JAVASCRIPT
var $message = $('#message');var $testChange = $('#testChange');var i = 1;function updateChange() { $message.html($message.html() + 'Changed to ' + $testChange.val() + '
');}$testChange.on('change', updateChange);setInterval(function() { $testChange.val(++i).trigger('change');; console.log("value changed" +$testChange.val());}, 3000);updateChange();
should work as expected.
转载:http://stackoverflow.com/questions/6533087/jquery-detect-value-change-on-hidden-input-field