Reputation: 63
i have a url value from the json response which is like
url=response.url.urlname;(//suppose this contains the value like www.google.com)
now i want to include it in anchor tag in my javascript code web is div in html page
<div id="web>
$("#web").append('<a href="http://"'+url+'"" rel="external" data-direction="reverse">'+url+'</a>');
i am unable to load the page.can anybody help me for this concatenation?
Upvotes: 0
Views: 5781
Reputation: 26277
Seems as you are using bad quotation
var url = "www.google.com"
var link = '<a href="http://"'+url+'"" rel="external" data-direction="reverse">'+url+'</a>'
// returns: "<a href="http://"www.google.com"" rel="external" data-direction="reverse">www.google.com</a>"
var url = "www.google.com"
var link = '<a href="http://'+url+'" rel="external" data-direction="reverse">'+url+'</a>'
// returns: "<a href="http://www.google.com" rel="external" data-direction="reverse">www.google.com</a>"
Upvotes: 0
Reputation: 15699
It seems that you have not used quotes properly.
Try this:
$("#web").append("<a href='http://"+url+"' rel='external' data-direction='reverse'>"+url+"</a>");
OR this:
$('#web').append('<a href="http://'+url+'" rel="external" data-direction="reverse">'+url+'</a>');
Upvotes: 2