This feature has been removed from the Web standards. Though some browsers may still support it, it is in the process of being dropped. Avoid using it and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
anchor() method creates an
<a> HTML anchor element that is used as a hypertext target.
- A string representing the
nameattribute of the a tag to be created.
A string containing an
<a> HTML element.
anchor() method to programmatically create and display an anchor in a document.
In the syntax, the text string represents the literal text that you want the user to see. The
name parameter string represents the
name attribute of the
Anchors created with the
anchor() method become elements in the
var myString = 'Table of Contents'; document.body.innerHTML = myString.anchor('contents_anchor');
will output the following HTML:
<a name="contents_anchor">Table of Contents</a>
|ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'String.prototype.anchor' in that specification.
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
|Feature||Android||Chrome for Android||Edge mobile||Firefox for Android||IE mobile||Opera Android||iOS Safari|
1. Starting with version 17, the quotation mark (") is replaced by its HTML reference character (
") in strings supplied for the