使用锚标记Django在网址的另一个页面中链接div

use*_*087 2 django url anchor

我正在尝试使用Django中的定位标记和URL访问另一个页面中的div。

这是HTML,

<a href="{% url 'anotherpage#show' %}>click here </a>
Run Code Online (Sandbox Code Playgroud)

在另一页中

<div id="show">link to this div </div>
Run Code Online (Sandbox Code Playgroud)

如何show使用网址访问div?

Oth*_*man 6

您需要先链接到页面。然后链接到Anchor

## assume this will take you to the main page. 
<a href="{% url 'anotherpage' %}>Page URL</a>
Run Code Online (Sandbox Code Playgroud)

然后,您要做的就是在url标记后添加所需的锚点。

<a href="{% url 'anotherpage' %}#show">Page URL to show directly. </a>
Run Code Online (Sandbox Code Playgroud)

希望能帮助到你。