HTML DOM Anchor name attribute
Definition and Usage
name property sets or returns the name attribute value of the link.
name property returns the name of a link, usually used to create a bookmark on the document.
grammar
Setting name attribute:
anchorObject.name="name"
Returns the name attribute:
anchorObject.name
值 | 描述 |
---|---|
name | 设置链接的名称 |
Browser Support
All major browsers support attribute name
Examples
Examples
Returns the name of the link:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
</head>
<body>
<p><a href="#C6">参见第6章</a></p>
<h2>第1章</h2>
<p>这一章解释了 ba bla bla</p>
<h2>第2章</h2>
<p>这一章解释了 ba bla bla</p>
<h2>第3章</h2>
<p>这一章解释了 ba bla bla</p>
<h2>第4章</h2>
<p>这一章解释了 ba bla bla</p>
<h2>第5章</h2>
<p>这一章解释了 ba bla bla</p>
<h2><a id="c6" name="C6">第6章</a></h2>
<p>这一章解释了 ba bla bla</p>
<script>
document.write("返回锚: ");
document.write(document.getElementById("c6").name);
</script>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
</head>
<body>
<p><a href="#C6">参见第6章</a></p>
<h2>第1章</h2>
<p>这一章解释了 ba bla bla</p>
<h2>第2章</h2>
<p>这一章解释了 ba bla bla</p>
<h2>第3章</h2>
<p>这一章解释了 ba bla bla</p>
<h2>第4章</h2>
<p>这一章解释了 ba bla bla</p>
<h2>第5章</h2>
<p>这一章解释了 ba bla bla</p>
<h2><a id="c6" name="C6">第6章</a></h2>
<p>这一章解释了 ba bla bla</p>
<script>
document.write("返回锚: ");
document.write(document.getElementById("c6").name);
</script>
</body>
</html>
Examples of the above output:
Back anchor: C6
try it"
Anchor objects