jQuery append function giving syntax error in console.log -


$(".trade-button").append('<div> <button tabindex="2" class="btn google-analytics-make-trade-click-trade-page"<span id="tradetotal"></span> </button></div>'); 

i'am trying append html, it's giving syntax error.

the problem wrote appending string in multiple lines. can't this, not valid javascript. can write in 1 line, or escape correctly.

$(".trade-button").append('<div><button tabindex="2" class="btn google-analytics-make-trade-click-trade-page">trade total of $0<span id="tradetotal"></span></button></div>');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <div class="trade-button"></div>

or:

$(".trade-button").append('<div>' +                             '<button tabindex="2" class="btn google-analytics-make-trade-click-trade-page">' +                             'trade total of $0' +                             '<span id="tradetotal"></span>' +                             '</button></div>');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <div class="trade-button"></div>


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -