html a标签传值
Links are defined using the a
tag. The link destination is set via its href
attribute.
链接是使用a
标签定义的。 链接目标是通过其href
属性设置的。
Example:
例:
<a href="https://flaviocopes.com">click here</a>
Between the starting and closing tag we have the link text.
在开始标记和结束标记之间,我们有链接文本。
The above example is an absolute URL. Links also work with relative URLs:
上面的示例是绝对URL。 链接也可以使用相对URL:
<a href="/test">click here</a>
In this case, when clicking the link the user is moved to the /test
URL on the current origin.
在这种情况下,单击链接时,用户将移动到当前来源的/test
URL。
Be careful with the /
character. If omitted, instead of starting from the origin, the browser will just add the test
string to the current URL.
请注意/
字符。 如果省略,则浏览器将代替将test
字符串添加到当前URL,而不是从起点开始。
Example, I’m on the page https://flaviocopes.com/axios/
and I have these links:
例如,我在页面https://flaviocopes.com/axios/
,我具有以下链接:
/test
once clicked brings me tohttps://flaviocopes.com/test
/test
一次单击即可将我带到https://flaviocopes.com/test
test
once clicked brings me tohttps://flaviocopes.com/axios/test
单击一次
test
即可将我带到https://flaviocopes.com/axios/test
Link tags can include other things inside them, not just text. For example, images:
链接标签可以在其中包含其他内容,而不仅仅是文本。 例如,图像:
<a href="https://flaviocopes.com">
<img src="test.jpg">
</a>
or any other elements, except other <a>
tags.
或其他任何元素,但其他<a>
标记除外。
If you want to open the link in a new tab, you can use the target
attribute:
如果要在新选项卡中打开链接,则可以使用target
属性:
<a href="https://flaviocopes.com" target="_blank">open in new tab</a>
html a标签传值