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 | Description |
---|---|
url | Required. The URL to link to |
A string embedded in the <a> tag
The following code shows how to Display the text: "Tutorials!" as a hyperlink:
<!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>