Latest web development tutorials

JavaScript anchor () method

String Object Reference JavaScript String Object

Definition and Usage

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

This method returns a string <a> add tags, as follows:

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

grammar

string.anchor(name)

参数 描述
name Required. The name of the anchor


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support anchor () method.


Examples

Examples

Create an HTML anchor:

<script>

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

</script>

try it"


String Object Reference JavaScript String Object