JavaScript anchor() method


JavaScript anchor() Method


Definition and usage


anchor() method is used to create HTML anchors .

This method returns a string with the <a> tag, as shown below:

<a name="anchorname">string</a>

Syntax

string.anchor(name)

##ParametersDescriptionnameRequired. The name of the anchor


View Browser Support

QQ截图20161108165429.png

All major browsers support the anchor() method.


Instance

Instance

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">

</head>
<body>

<script>
var txt="Chapter 10";
txt.anchor("chap10");
alert(txt.anchor("chap10"));
</script>

</body>
</html>

Run Instance»Click "Run Instance" Button to view online examples