Reply LinkBack Thread Tools Search this Thread
Old 18-02-2010, 16:27   #1 (permalink)
KrisMarissens
or just Kris
 
KrisMarissens's Avatar
 
Join Date: Jun 2005
Location: Brussels - Belgium
Posts: 176
jQuery+switch/case to show <ul> type of question

Hello fine people of DT,

I am writing a little .js file that looks for the pathname in order to show an <ul> conditionally. Here's how I am trying this:

Code:
var checkUrl = document.location.pathname.toLowerCase(); switch (checkUrl) { case '/root/documentA.html': $('.classname').show(); break; case '/root/documentB.html': $('.classname').show(); break; ... }
At this time I have at least 60 different cases (different document names).

My question is: is there a more efficient way of dealing with this without touching the markup (Meaning only using the external .js file) ?

Thanks a lot.

Last edited by KrisMarissens : 18-02-2010 at 19:53.
  Reply With Quote
Old 18-02-2010, 19:47   #2 (permalink)
Shiro
Whitey
 
Shiro's Avatar
 
Join Date: Aug 2007
Location: Yokohama, Japan
Posts: 7,313
What?
__________________
This space for rent.

After Hours Japan
  Reply With Quote
Old 18-02-2010, 21:43   #3 (permalink)
7twelve
has bucket
 
7twelve's Avatar
 
Join Date: Aug 2008
Posts: 571
would help to see the markup in question
  Reply With Quote
Old 19-02-2010, 15:04   #4 (permalink)
KrisMarissens
or just Kris
 
KrisMarissens's Avatar
 
Join Date: Jun 2005
Location: Brussels - Belgium
Posts: 176
Code:
<ul> <li class="predoctorale-mandaten main-item"><h2><a class="section-nav" href="Predoctorale-mandaten.aspx">Predoctorale mandaten</a></h2> <ul class="subnav"> <li class="aspirant"><a href="Aspirant.aspx">Aspirant</a></li> <li class="bijzondere-doctoraatsbeurs"><a href="Bijzondere-doctoraatsbeurs.aspx">Bijzondere doctoraatsbeurs</a></li> <li class="klinische-doctoraatsbeurs"><a href="Klinische-doctoraatsbeurs.aspx">Klinische doctoraatsbeurs</a></li> <li class="predoctorale-mandaten-info"><a href="Predoctorale-mandaten-info.aspx">Informatie en formulieren</a></li> <li class="faq"><a href="Faq-Predoctorale-mandaten.aspx">Faq</a></li> </ul> </li> </ul>

The hyperlinks are the pages where the .subnav of '.predoctorale-mandaten' need to be shown.

Hope this bit clears it up a little. If not I'll post a live example.
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive
Web Hosting by Heart Internet, vBulletin © 2000-2009 Jelsoft Enterprises Limited.
Search Engine Optimization by vBSEO 3.0.0 RC8
Web Hosting by Heart Internet