此方法创建用作超文本目标的HTML锚点。
string.anchor(anchorname )
anchorname - 定义锚点的名称。
返回具有锚定标签的字符串。
<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>
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)