Am new to jQuery and wondering if any could advise me on best practise...
I am looking to append a div element to the page, which contains a lot of html and not sure wha
Currently there are following methods:
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.