X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

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

Internet Explorer Firefox Opera Google Chrome Safari

The anchor() method is supported in all major browsers.


Syntax

string.anchor("name")

Parameter Values

Parameter Description
name Required. The name of the anchor

Return Value

Type Description
String A string embedded in the <a> tag


JavaScript String Reference JavaScript String Reference

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook