简体   繁体   中英

HTML href to an element with an ID

In my HTML code, I have a list element ID such as:

<li id="pageHome">

And, when I want to reference to it, I have:

<h1><a href="#!/pageHome" id="logo">Interior</a></h1>

This works fine, however, when I load my website, I noticed that when I want to go my home page, the link looks like this:

mywebsite.com/#!/pageHome

I don't think this looks professional. Is there anything that I can do such that anytime that I want to go to main page, it shows something like this instead?

mywebsite.com/pageHome

破折号将始终出现,但是您可以防止反斜杠和感叹号出现在URL中,因为编写href =“#pageHome”就足够了

#pageHome should work perfectly fine.

Also check How do I scroll to an element using JavaScript? for JS solutions!

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