String link() Method - Javascript String

Javascript examples for String:link


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>

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

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

function myFunction() {//from w  ww .  j a v a  2s .  c o m
    var str = "Tutorials!";
    var result ="");
    document.getElementById("demo").innerHTML = result;


Related Tutorials