[jQuery] finding if a link exists, or what it's prepended with
Hi all :-)
jQ newbie here who's finding it much less intuitive than I anticipated
to figure things out...
Wish the examples were a bit more diverse, because I'm having to try
20 variations of every little thing before it works.
Anyway... At the moment, I have just one thing I still need to find.
Let's say:
var page = location.pathname.substring(1) // current page, e.g.
"home.htm"
I have a navigation menu with submenus. The 'page' link will be in
either a <dt> tag or a <li> tag.
<dl>
<dt><a href="category-1.htm">Category-1</a></dt>
<dd>
<ul>
<li><a href="item-1.htm">Item 1</a></li>
<li><a href="item-2.htm">Item 2</a></li>
</ul>
</dd>
[etc.]
</dl>
I now need to know either one of these...
1) how do I say...
if ( " <li class="current"><a href=" " + page ) exists
or...
2) if ( "<a href="" + page is prepended by <li> ) // [ instead of
prepended by <dt> ]
or... (less optimal)
3) if I can count how many times class="current" appears on the
page....?
Thanks in advance!