Saturday, 24 August 2013

Jquery variable within quotes returning Syntax Error

Jquery variable within quotes returning Syntax Error

I am really confused with the simplest thing. Can anyone please help me on
this one?
I've got the following code:
$('#nav a').click(function(){
var $href = $(this).attr('href');
if(!$($href).hasClass('top')){
console.log("'#" + $href + "'");
}
});
And it logs this every time I "click" on an link within "#nav":
Uncaught Error: Syntax error, unrecognized expression
Any clues?
Thanks ;)

No comments:

Post a Comment