I have:
<input name="X">
and in JavaScript:
$('input').on('change','[name=X]',function() {
$('body').append('on change fired!');
}
);
$('input[name=X]').change(function() {
$('body').append('change fired!');
});
$(input[name='X']).val('test');
But my problem is that neither change event gets fired.
Changing the value of an input element programatically will not trigger any event. Alternatively, You can call
.changeafter.vallike below,Edit: Also fixed the missing quotes around the input selector.
DEMO: http://jsfiddle.net/G6n4h/1/