Whenever I have to pass variables from Python to JavaScript, I usually do it
like this to avoid problems, and to make the code cleaner:
var target = '#page-{{=page.id}}';
jQuery(target).click(function() {
alert('clicked');
});
A quick note about this. ID, NAME, and CLASS HTML attributes need to start
with a letter. They cannot start with a number[1]. In the sample above, you
will notice that the ID starts with the word 'page', so when viewing the
HTML source, it would look like this: page-25.
References:
[1] http://www.w3.org/TR/html401/types.html#type-name