String link() Method - Javascript String

Javascript examples for String:link

Description

The link() method is used to display a string as a hyperlink, which returns the string embedded in the <a> tag, like this:<a href="url">string</a>

Parameter Values

Parameter Description
url Required. The URL to link to

Return Value:

A string embedded in the <a> tag

The following code shows how to Display the text: "Tutorials!" as a hyperlink:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

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

<p id="demo"></p>

<script>
function myFunction() {//from w  ww .  j a v a  2s .  c o m
    var str = "Tutorials!";
    var result = str.link("https://www.java2s.com");
    document.getElementById("demo").innerHTML = result;
}
</script>

</body>
</html>

Related Tutorials