描述
此方法将创建一个用作超文本目标的 HTML 锚点。
语法
它的语法如下 -
string.anchor( anchorname )
属性详细信息
anchorname - 定义锚点的名称。
返回值
返回具有 anchor 标签的字符串。
例请尝试以下示例。
<html>
<head>
<title>JavaScript String anchor() Method</title>
</head>
<body>
<script type = "text/javascript">
var str = new String("Hello world");
alert(str.anchor( "myanchor" ));
</script>
</body>
</html>
输出
<a name = "myanchor">Hello world</a>