Create an anchor link element from string object in JavaScript

Description

The following code shows how to create an anchor link element from string object.

Example


<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
var myString = new String();<!-- w w  w.  ja va2  s  . c  o m-->
myString = "java2s.com";
document.writeln(myString.link("http://java2s.com"));


</script>
</body>
</html>

Click to view the demo

The code above generates the following result.

Create an anchor link element from string object in JavaScript