0
   $('document').ready(function(){
$('#gfooter').append("<div style="text-align:center; width:800px; margin-left:auto; margin-right:auto;">
<img id="Image-Maps_3201211230108478" src="http://i.imgur.com/aHKja.png" usemap="#Image-Maps_3201211230108478" border="0" width="800" height="400" alt="" />
<map id="_Image-Maps_3201211230108478" name="Image-Maps_3201211230108478">
<area shape="rect" coords="84,184,253,353" href="www.facebook.com" alt="Facebook" title="Facebook"    />
<area shape="rect" coords="316,184,485,353" href="www.twitter.com" alt="Twitter" title="Twitter"    />
</map>
</div>
");
});

I'm trying to .append this bit of html into the div #gfooter. though it does not seem to work. Can anyone explain to my why?>

EasyBB
  • 6,176
  • 9
  • 47
  • 77

2 Answers2

1

Anytime you're putting something inside double quotes, the next time you use double quotes it "escapes". Therefore, use either one of these formats:

$.append("<a href='#'>link</a>");

$.append('<a href="#">link</a>');

I prefer the second one because it allows me to type my HTML like I usually do (using double quotes). Hope it helps!

bentedder
  • 796
  • 6
  • 21
  • Ok, so I escaped it. though it still is not working? any suggestions? I'll make a jsfiddle – EasyBB Nov 23 '12 at 20:07
  • actually I got it to work. I had to make all the html one line and fix the image map to show correctly. Thank you. – EasyBB Nov 23 '12 at 20:25
  • Yeah, I should have mentioned that as well, needs to be in one line :). Glad it works. – bentedder Nov 24 '12 at 00:21
  • Could you also help me with something? I want to find http://i34.servimg.com/u/f34/17/74/08/92/icon_u11.png or #i_icon_online and if it does not exist .html(''); I tried $(function() { $('.post:not("img#i_icon_online")').add('.post').html('offline'); });​ did not work – EasyBB Nov 24 '12 at 00:35
  • You do not need to make it one line! Just escape the new line. http://stackoverflow.com/questions/805107/how-to-create-multiline-strings – Brad Nov 24 '12 at 06:58
0

You need to escape quotes in string literals with a backslash.

var somestring = "<div id=\"something\">";
Brad
  • 159,648
  • 54
  • 349
  • 530