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
  • 1
  • 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
  • 132,252
  • 13
  • 159
  • 168
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,264
  • 13
  • 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
  • 28,279
  • 5
  • 35
  • 57
0

You are missing some quotes...

use:

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