I'm creating a script that allows me to launch pop-in windows based on the URL's hashtag. I'm able to get it to work when the user plugs in the URL+hash directly in the location bar. However, when the anchor links are clicked, the script doesn't seem to perform the .load() function. Is my sequencing wrong, or am I going about this the completely wrong way?
<script>
$(document).ready(function() {
var loc = window.location.hash;
var container = $('.container');
if ( loc == "#content1" ) { $('.container').load('content1.html') }
if ( loc == "#content2" ) { $('.container').load('content2.html') }
});
</script>
<body>
<ul class="navigation">
<li><a href="#content1">Launch content1</a></li>
<li><a href="#content2">Launch content2</a></li>
</ul>
<div class="container"></div>
</body>