Create link (href) attribute with Javascript

With below code you can easily create link attribute (href) with pure javascript.



<html>

<head></head>

<body>

<script>


var a = document.createElement('a');

var linkText = document.createTextNode("My Company");

a.appendChild(linkText);

a.title = "My Company";

a.href = "http://iflair.com/";

document.body.appendChild(a);


</script>

</body>

</html>

Post a Comment

0 Comments