ToddT ToddT - 1 year ago 72
HTML Question

jQuery append with variable as src

Just learning jQuery and cannot get my variable into

when I use
. It either doesn't work at all, or I just get the string representation of my variable name when I look in the console.

This is my offending code:

var $googleURL = ""+$googleStreet+","+$googleCity;

$($body).append('<img src='$googleURL'></img>');

I don't want to use
because there is no
tag on the page, just a
tag. Where did I go astray?

Answer Source

please try

  $($body).append("<img src='"+ $googleURL + "'></img>");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download