Home > Article > Web Front-end > A brief discussion on the usage of anchor() method in JavaScript
In this article, we will learn about the use of anchor() in JavaScript. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
Definition and usage:
anchor() method is used to create HTML anchors.
This method returns a string with <a> 标签</a>
added, as shown below:
<a name="anchorname">string</a>
Syntax:
string.anchor(name)
Parameters: Description:
name Required. The name of the anchor
Browser support:
The code demonstration is as follows:
<!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>
The running results are as follows:
Recommended learning: "PHP Video Tutorial》