So I have a tabbed navigation system, and I am using jquery to
auto-select the current tab.
Here's the html:


<ul id="main_nav">
  <li> /services/ SERVICES </li>
  <li> /store/ STORE </li>
  <li> /about-us/ ABOUT US </li>
  <li> /gallery/ GALLERY </li>
  <li> /press/ PRESS </li>
</ul>


Here's my jQuery code (adapted from
http://leftlogic.com/info/articles?id=1):


if (location.pathname.substring(1)) {
   $('#main_nav [EMAIL PROTECTED]"' + location.pathname.substring(1) +
'"]').parent().attr('id', 'current');
}

I'm using parent() so that the id gets applied to the 'li' element and
not the 'a' element.

All of this works. However, I'm unclear about a couple of things:

First, why is the dollar sign $ necessary in the xpath statement? i've
seen no documentation on it, and when i try it without the dollar sign,
it doesnt work.

Second, Sometimes I have a url like: /about-us/4/3 and my jQuery
statement fails because the href != location.pathname.
How can i rewrite this statement so that it searches for the href value
in the location.pathname value and applies the id to the matching
string?

Thanks in advance,
dd
-- 
View this message in context: 
http://www.nabble.com/Xpath-and-tab-selection-tf2563069.html#a7143657
Sent from the JQuery mailing list archive at Nabble.com.


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to