简体   繁体   中英

How to use anchor tag to click on particular span

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!

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM