onchange hidden input code example

Example: onchange value in hidden input

//in the HTML: <input id="myValue" type="hidden" name="myValue" value="">
$(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:
$('#myValue').val('the new value').triggerHandler('change');
//That's because onchange event is not fired automatically changing its value programatically.