Home > Web Front-end > JS Tutorial > body text

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

PHPz
Release: 2021-05-31 16:36:06
Original
3330 people have browsed it

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>
Copy after login

Syntax:

string.anchor(name)
Copy after login

Parameters: Description:

name     Required. The name of the anchor
Copy after login

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>
Copy after login

The running results are as follows:

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

Recommended learning: "PHP Video Tutorial

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!