$(document).ready(function(){
var page = window.location.hash;
if(page != ""){
$('a[href='+ page +']').addclass('selected');
pageload(page.replace('#/page/', 'pages/?load='));
}
$('#top a').click(function(event){
$('#top a').removeClass('selected');
$(this).addClass('selected');
pageload($(this).attr('href').replace('#/page/', 'pages/?load='));
event.preventDefault;
});
});
<div id="top">
<a href="#/page/link">Link</a>
<a href="#/page/link">Link</a>
<a href="#/page/link">Link</a>
<a href="#/page/link">Link</a>
<a href="#/page/link">Link</a>
</div>
So when i’m trying to do this, and load up a page using the window.location.hash, i get an error in the console saying:
Uncaught Error: Syntax error, unrecognized expression:
[href=#/page/link]
How can i make this work?
Try this instead:
(You need to escape the value of the
href– with this, you geta[href="#/page/link"].)