Javascript - String anchor() Method

The anchor() method creates an HTML anchor. This method returns the string embedded in the <a> tag, like this:

Description

The anchor() method creates an HTML anchor. This method returns the string embedded in the <a> tag, like this:

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

Syntax

string.anchor("name")

Parameter Values

Parameter Require Description
name Required. The name of the anchor

Return

A string embedded in the <a> tag

Example

Create an HTML anchor around a string:

Demo

var txt = "test";
console.log(txt.anchor("link"));

Result