问题
This is my link to the specific page from another page.
<a href="http://test.com/#test"
and this is my part of page I want to display but it does not work...
<div id="test"><h4>Title of test</h4></div>
I am using WordPress, could it cause the problem?
回答1:
Change this:
<div id="test">
<h4>
Title of test
</h4>
</div>
to this...
<a name="test">
<h4>
Title of test
</h4>
</a>
You should be able to link to it with this:
<a href="http://test.com/test-page#test">Test</a>
回答2:
In HTML, you can jump to a specific page section by using an anchor tag with a name or id attribute, like:
<a id="test"><h4>Title of test</h4></a>
or
<a name="test"><h4>Title of test</h4></a>
Actually, it looks like name was only for HTML4, ID is what should be used for HTML5 per here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-name
来源:https://stackoverflow.com/questions/28503383/redirect-to-a-specific-part-of-the-page-with-a-link