Saturday 15 May 2010

jQuery - Syntax Error -


I am using the following to identify the currently selected (active) link in the site:

< Pre> $ (function () {var path = location.pathname.substring (1); if (path) $ ('# sidebar_content a [@ href $ =' '+ + path +' "] '). Atr ('class', 'selected');}); It appears to correctly identify the path, but it also generates an error.

Error: : Syntax error, unrecognized expression: [@ href $ = "/ Ohs_north_carolina"

The source of the page does not show that the class is added to the link.

Appreciate some help.

Thanks.

[@ attr] remove style selectors in jQuery 1.3 Remove the @ symbol and it should work.

  $ ('# sidebar_content a [href $ = "' + + path + '"]' ). Attr ('class', 'selected');  

to:

Note: jQuery 1.3 [@attr] style selectors have been removed Was (they first demoted in jQuery 1.2 े).

Just remove the '@' mark from your selectors.

No comments:

Post a Comment