THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

JavaScript String anchor() Method

JavaScript String Reference JavaScript String Reference

Example

Create an HTML anchor around a string:

var txt = "Chapter 10";
txt.anchor("chap10");
alert(txt.anchor("chap10"));
Try it Yourself »

Definition and Usage

The anchor() method is not standard, and may not work as expected in all browsers.

The anchor() method is used to create an HTML anchor.

This method returns the string embedded in the <a> tag, like this:

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


Browser Support

Method
anchor() Yes Yes Yes Yes Yes

Syntax

string.anchor("name")

Parameter Values

Parameter Description
name Required. The name of the anchor

Technical Details

Return Value: A string embedded in the <a> tag
JavaScript Version: 1.0

JavaScript String Reference JavaScript String Reference