I need to show a block when the button is clicked, so I do this :
var container = $('#container');
$('button').on('click', container.show);
and it doesn't work, however, when I write this, it works :
var container = $('#container');
$('button').on('click', function() {
container.show()
});
Can somebody explain me why the first version doesn't work ? Is there a way to use show method without writing an anonymous function in the event handler ?