How to use anchor tag to click on particular span

Viewed 32

all sorry for the very basic or maybe a silly question but I was trying to do something which I am not sure, can be done by using an anchor tag or not. After searching over the internet I didn't find any perfect solution for that so here I am writing this question.

Problem - I want to redirect my page from index.php to about.php, and I also want to open one div that can be only visible if we click on it. How to do that using an anchor tag?

I tried - <a href="about#my_div_id"> unfortunately, It didn't work I think maybe because I have to also click on that particular div to make it open. Anyone can please help me out I need some solution to do this. I am using angularJs so if it can be done by that, please help!

1 Answers

Could you parse the URL in JavaScript on page load, open the div, and set document.documentElement.scrollTop to the position of the div on your page?

Something like:

# On page load:
#   if $parsedURL has $hash:
#     div.show()
#     window.scrollTo(div.position)
Related