String anchor() Method - Javascript String

Javascript examples for String:anchor

Description

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>

Parameter Values

Parameter Description
name Required. The name of the anchor

Return Value:

A string embedded in the <a> tag

The following code shows how to Create an HTML anchor around a string:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<script>
function myFunction() {//  w  w  w .j a  v a 2s  . c  o m
    var txt = "test";
    txt.anchor("anchor link");
    console.log(txt.anchor("chap10"));
}
</script>

</body>
</html>

Related Tutorials