On my blog I have a lot of blocks containing code snippets.
What I want to do is add a .click()
handler to all the
Not sure I would handle it this way, probably I would simply pop up a dialog with the code rather than leave the page, but you could handle this by building a form using javascript then triggering a submit on that form instead of using AJAX.
Using dialogs with jQuery UI:
$('pre').on('click', function() {
$('' + $(this).text() + '
').dialog({
... set up dialog parameters ...
});
});
Build a form
$('pre').on('click', function() {
var text = $(this).text();
$('')
.appendTo('body');
$('[name="code"]').val(text);
$('.hidden-form').submit();
});