0

When I do the following:

var foo = '<p><img src="tracking.pixel.outside.my.domain /></p>';
$("#outputdiv").html(foo);

This is what shows up in outputdiv: <p></p>

Is there some reason that this shouldn't work? I'm running out of ideas. I've also tried using innerHTML, to no avail.

2
  • 2
    src="tracking.pixel.outside.my.domain" - missing " at the end? Commented Oct 19, 2011 at 7:25
  • your missing a " on the img src tag, but not sure if that's the problem? Commented Oct 19, 2011 at 7:26

2 Answers 2

5

Your HTML is invalid (missing quote).

Replace

var foo = '<p><img src="tracking.pixel.outside.my.domain /></p>';

with

var foo = '<p><img src="tracking.pixel.outside.my.domain" /></p>';
Sign up to request clarification or add additional context in comments.

1 Comment

Well that's embarrassing hahah. Thanks.
-1

You should replace

var foo = '<p><img src="tracking.pixel.outside.my.domain /></p>';

with

var foo = "<p><img src='tracking.pixel.outside.my.domain' /></p>";

I think simple quotes must be inside double quotes.

2 Comments

You can definitely do it either way but you'll notice that you fixed my typo too hah.
Most languages which do not have a special char datatype (such a C) allow " and ' to be used for string quoting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.