hidden input change event

chokrijobs picture chokrijobs · Sep 25, 2012 · Viewed 37.2k times · Source

How can I detect a change of the value of a hidden input? I've already tried these approaches without success:

$('#id_inpout').live('change',function () {
        var id_el = $(this).attr('id');
        alert(id_el);
    });

and

$('#id_inpout').change(function () {
        var id_el = $(this).attr('id');
        alert(id_el);
    });

and

$('#id_inpout').bind('change',function () {
        var id_el = $(this).attr('id');
        alert(id_el);
    });

Answer

Alex picture Alex · Feb 12, 2013

You could also use trigger('change') after you assign new value to the hidden input:

$('#hidden_input').val('new_value').trigger('change');