Home  >  Article  >  Web Front-end  >  A brief discussion on the usage of anchor() method in JavaScript

A brief discussion on the usage of anchor() method in JavaScript

PHPz
PHPzOriginal
2016-05-16 15:02:273356browse

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.

A brief discussion on the usage of anchor() method in JavaScript

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:

A brief discussion on the usage of anchor() method in JavaScript

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:

A brief discussion on the usage of anchor() method in JavaScript

Recommended learning: "PHP Video Tutorial

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn