JavaScript string anchor() Method (original) (raw)
Last Updated : 16 Jul, 2024
The JavaScript **anchor() method creates an anchor element that is used as a hypertext target that means when you use the anchor method in JavaScript the anchor method returns elements with string and also returns "anchorname" as the value of "name" attribute like _this:
**Syntax:
string.anchor(anchorname)
**Note: This method has been DEPRECATED and is no longer recommended.
**Parameters:
This method accepts a single parameter.
- **anchorname: The name of the anchor.
**Return Value:
The **anchor() method returns the string with element.
**Example 1: This example shows the basic use of the anchor tag in Javascript.
JavaScript `
let str = "GFG"; console.log(str.anchor("anchorname"));
`
Output
**Example 2: This example shows you how to use **anchor() method.
JavaScript `
let str = "GeeksForGeeks"; console.log(str.anchor("anchorname"));
`
Output
**Supported Browsers:
- Chrome 1
- Edge 12
- Firefox 1
- Opera 3
- Safari 1