0

So I have a page that has multiple divs that can be toggled to be visible/invisible by the user.

Then I have another page that I want to link to something specific in the aforementioned page. How can I pass the javascript toggle code along with the link so that it displays the correct div, instead of just the default view.

1 Answer 1

1

You could use a url hash like site.com/page.html#div1

Then use javascript to parse the hash and decide wich div to show

var hash = window.location.hash;
var selectedDiv = hash.split('#')[1];

//Then show selectedDiv
Sign up to request clarification or add additional context in comments.

1 Comment

oh so thats how you do that. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.