Reputation: 4564
I'm trying to generate a valid span tag via jQuery:
$("#commentsSection").append("<span class='myClass'>");
$("#commentsSection").append("</span>");
I'm using Spring Boot and Thymeleaf and such html won't render due to:
SyntaxError: missing ) after argument list
$("#commentsSection").append("<span class="myClass">");
Should I esape quotes somehow?
Upvotes: 0
Views: 190
Reputation: 2199
If your javascript is directly in the html file then surround it with a CDATA-Block so thymeleaf doesn't try to render it.
<script>
// <![CDATA[
.
. your code
.
// ]]>
</script>
Upvotes: 1
Reputation: 65
You need to put escape char like this,
"<span class=\"myClass\">"
Hope it works!
Upvotes: 0
Reputation: 15875
Escape the quotes or use '
single quote inside.
$("#commentsSection").append("<span class='myClass'>");
or
$("#commentsSection").append("<span class=\"myClass\">");
Upvotes: 0