0

I am trying to add link of same hyperlink of same link in html but it not linking

in html simple add a link http://www.test.com/test

but link is not generating

I want to change automatically result as <a href="http://www.test.com/test">http://www.test.com/test</a> for example http://www.test.com/test

Kamlesh Kumar
  • 1,632
  • 2
  • 21
  • 31

2 Answers2

0

You can do this with a simple script.

Step 1: Add hyperlink with id

<a href="#" id="link">Link Comes Here</a>

Step 2: On dom ready get page url and update the href value with jQuery.

$(document).ready(function() {
     var url = window.location.href; 
     // if you have static url you can hard code like
     // var url = "http://www.url.com"; 
     $("#link").attr("href", url)
});
KiV
  • 2,225
  • 16
  • 18
  • make sure you provide information on jQuery; it might be self-explanatory to you, but the OP hasn't even mentioned javascript at all, so you cannot be sure they know what jQuery is... – benomatis Nov 03 '14 at 06:08
0

try this in you HTML:

<a href="http://www.test.com/test"><span>http://www.test.com/test</span></a>

else try to use jquery like this:

HTML:

<a href="http://www.test.com/test" id="myLink"></a>

JQuery:

$(document).ready(function(){
    $("#myLink").text("http://www.test.com/test");
});