0

I'm very new to JQuery and have what is probably a very basic query.

I am trying to append a series of tags including a script into a DIV with a ID, I keep on getting the error:

'Uncaught Syntax Error: Unexpected token ILLEGAL'

this is the script:

<script>
 $("#addBender").click(function() {
  alert("Handler for .click() called.");
  $(".addBender").append('<pre class="_cssdeck_embed" data-pane="output" data-user="devilsbackyard" data-href="dancing-robot-with-reflection" data-version="0"></pre>\<script async src="http://cssdeck.com/assets/js/embed.js"></script>');
 });
</script>

The HTML click element (#bender) and DIV (class="addBender") to append to.....

<div class="gradientbuttons" id="addBender" class="clickSlide">
    <ul class="redtheme">
       <li><a href="#">Sad man walks slowly</a></li>
    </ul> 
</div>

<!--add bender here when button clicked-->
<div class="addBender"></div>
1
  • if addBender is ID then $('#addBender').append() is the syntax. try adding your code to fiddle. Commented Oct 26, 2013 at 12:39

1 Answer 1

2

Try this :

$("#addBender").click(function() {
 alert("Handler for .click() called.");
 $(".addBender").append('<pre class="_cssdeck_embed" data-pane="output" data-user="devilsbackyard" data-href="dancing-robot-with-reflection" data-version="0"><'+'/'+'pre><script async src="http://cssdeck.com/assets/js/embed.js"><'+'/'+'script>');
});

JsFiddle Demo

Sign up to request clarification or add additional context in comments.

2 Comments

Ill try that. But what's JFiddle??
@dancingbush It's a site for online demos (html,css,js,jquery). jsfiddle.net

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.