AFAIK, there is no way to do this withing pure jQuery. You want to manipulate the browser history to add routing to your application, and to do this you require either a jQuery plugin, or directly with the native APIs of the browser: listening to the hashchange
event and/or the HTML5 History API.
Quick and dirty toy example to "clear" your div
:
$(document).on('click', 'button#page2', function() {
$("div.content-container").load("page2.html");
location.hash = '#page2';
});
$(window).on('hashchange', function() {
if (location.hash === '') {
$("div.content-container").html('');
}
});