Create an anchor link from string object in JavaScript

Description

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

Example


<!--  w w w.j  a  v  a 2  s.c  o  m-->
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
var myString = new String();
myString = "java2s.com";
document.writeln(myString.anchor("java2s.com"));


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

Click to view the demo

The code above generates the following result.

Create an anchor link from string object in JavaScript