0

I have a toggle slide. Is it possible to achieve the functionality below?

When I open an anchor link (that relies on id), e.g. http://websitename.com/page#name, the toggle slides are opened.

However, when I open the link without an anchor name, e.g. http://websitename.com/page, the toggle is closed.

Here is my toggle

Many thanks for any advice

4

2 回答 2

1

I'm not sure exactly what you mean but is this what you want?

if(window.location.hash === "name"){
     $('.showpanel').show();
     $('.showpanel2').show();
}

http://jsfiddle.net/9EFNK/21/

于 2012-11-01T09:37:51.330 回答
1

Perhaps something like

if(window.location.hash === "#showpanel") {
  $('.showpanel').slideToggle('slow');
}

If you changed your div classes to ids, you could probably code something a little more elegantly with

$(window.location.hash).show();
于 2012-11-01T09:46:21.157 回答