Im trying to append a large block of text using jquery\'s append().
$(\'#add_contact_btn\').click(function(event) {
event.preventDefault();
var large =
By default, the HTML code containing wraps cannot be used with append/prepend
directly use 'or"
. However currently there are following methods to do that:
Use "+" to join HTML code pieces.
Use "\" to escape.
Use "`" (back-tick, grave accent), do not need any extra operations. This method is supported from ES2015/ES6 (Template literals).
Add a hidden tag
containing the same HTML code you need, e.g. , then use
.append($('#foo').html());
.
Now post some use scenarios to the first three methods
metioned above (just run them in the console of Chrome
browser.):
We can see their differences clearly.