$('.button') .on('click.loadPage', function() { $("#target").load('http://page'); $(this).off("click.loadPage"); }) .on('click.slideToggle', function(){ $("#target").slideToggle(); });
and in another way without global vars:
$('.button') .on('click', function() { if ( !$(this).data("loaded") ) { $("#target").load('http://page'); $(this).data("loaded", true); } $("#target").slideToggle(); });
andlrc
source share