JavaScript anchor() 方法


定义和用法

anchor() 方法用于创建 HTML 锚。

  1. stringObject.anchor(anchorname)
参数 描述
anchorname 必需。为锚定义名称。

实例

在本例中,我们会为文本添加一个锚:

  1. <html>
  2. <body>
  3. <script type="text/javascript">
  4. var txt="Hello world!"
  5. document.write(txt.anchor("myanchor"))
  6. </script>
  7. </body>
  8. </html>

上面的代码将输出为纯粹的 HTML:

  1. <a name="myanchor">Hello world!</a>

分类导航