I'm attempting to create a DOM element using jQuery. I would like to create this DOM element with an 'on input' event defined.
This works:
var headerInput = $('<input/>', {
'class': 'headerInput',
type: 'text'
});
headerInput.on('input', function() {
backgroundManager.get('activePlaylist').set('title', $(this).val());
});
This does not:
var headerInput = $('<input/>', {
'class': 'headerInput',
type: 'text',
input: function(){
backgroundManager.get('activePlaylist').set('title', $(this).val());
}
});
I was wondering why? I thought these two syntaxes were identical.