window.location returns the current URL in the browser's locator.
window.location.hash refers to the specific part of the page that the
URL refers too (the part that follow the #). So if you're visiting
http://example.org/index.html#foo then window.location would return
http://example.org/index.html#foo while window.location.hash returns
only #foo. You'll notice that the hash looks exactly like an ID
selector which I am hoping to use on the following code:

<div id="foo" class="accordionMenu">
<h3>Some Menu Item</h3>
<dl>
....
</dl>
</div>
[repeat for each item in the menu each with a different value for ID]

Now if I am able to use the value of window.location.hash as a
selector then I should get something similar to $('#foo dl').show().
Unfortunately though it appears that the jQuery method ($) only wants
to accept strings and objects.

On Apr 30, 6:06 pm, Jörn Zaefferer <[EMAIL PROTECTED]> wrote:
> poorgeek schrieb:> I'm having the hardest time trying to figure out how to 
> use a variable
> > in a selector. I have the following code that works as part of a basic
> > accordion menu but with a twist that if someone links to the page
> > using an internal link then that section of the menu defaults to open.
>
> > $(document).ready(function(){
> >   $('.accordionMenu dl').hide();
> >   if (window.location.hash) {
> >     $(window.location.hash+' dl').show();
> >   }
> > ...
> > }
>
> > Any ideas what I might be doing wrong or just haven't learned yet?
>
> Can you provide a bit more information? What is window.location.hash
> supposed to contain? How are the links looking like?
>
> --
> Jörn Zaefferer
>
> http://bassistance.de

Reply via email to