0

Hi I am trying to append url from the server and show the link to the user to click it but the 'click' doesn't work. Can you help me fix it?

Thank you!

$("#uurl").append("<p><a target='_blank' href="+data[1]+">"+data[1]+"</a></p>")
Thecoder
  • 63
  • 9

5 Answers5

1

I would recommend you to create element's using jQuery. It will prevent you from quotes mess.

//Create anchor
var a = $('<a />', {
            "target" : "_blank",
            "href" : data[1],
            "text" : data[1]
        });

//Create paragraph and append anchor
var p = $('<p />').append(a);

//Append Paragraph
$("#uurl").append(p)
Satpal
  • 129,808
  • 12
  • 152
  • 166
0

replace your code with

$("#uurl").append("<p><a target='_blank' href='"+data[1]+"'>"+data[1]+"</a></p>")
Satender K
  • 571
  • 3
  • 13
0

$("#uurl").append("<p><a target='_blank' href='"+data[1]+"'>"+data[1]+"</a></p>") Should work. You forgot quotes for the href attribute's value

user3154108
  • 1,204
  • 14
  • 23
0

You are missing quotes around href, try putting it using escape character

$("#uurl").append("<p><a target='_blank' href=\""+data[1]+"\">"+data[1]+"</a></p>")
Bhushan Kawadkar
  • 27,908
  • 5
  • 34
  • 57
0

You are missing some quotes...

use:

$("#uurl").append("<p><a target='_blank' href='"+data[1]+"'>"+data[1]+"</a></p>")
ekhaled
  • 2,900
  • 19
  • 24