I thought this would really straightforward, instead I just lost a morning to it!
var insert = '<div class="main_content_half_panel_circle" id="circle_' + c + '"></div><script type="text/javascript">$("#circle_' + c + '").live("click", function(){ $(".main_content_half_panel_info_wrap").animate("left", ' + c_x + ', 400, "easeOutQuint") });</script>';
In firebug I keep getting ‘unterminated string literal’ – I’ve tried a hundred variations, with different syntax, e.g. –
'$(".main_content_half_panel_info_wrap").animate({"left": ' + c_x + '}, 400, "easeOutQuint") });</script>'
…rebuilt the string from scratch, rebuilt it as a straight code block with no escaped characters and no variables included, then reinserted the ‘ + c + ‘ etc. Nothing. Have I gone code blind?
Any help VERY MUCH appreciated!
Page is at:
http://www.helicopterfir.com/dev
Scott
When you have
</script>inside a string in a script block, the browser thinks that the script block ends there. The script tag is simply parsed before the code inside it, so at that stage the browser doesn’t know that it’s inside a string.Split the string up in the middle the closing tag: