JavaScript anchor()Method

String 对象参考手册JavaScript String Object

Definition and Usage

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

This method returns the string with <a> tags added, as shown below:

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

Syntax

string.anchor(name)

Parameter Description
name Required. The name of the anchor


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the anchor() method.


Example

Example

Create an HTML anchor:

<script>

var txt = "Chapter 10";
txt.anchor("chap10");
alert(txt.anchor("chap10"));

</script>

Try it Yourself »


String 对象参考手册JavaScript String Object Other Extensions