Say that I have a <div class="statistics"></div>
that I need placed in 5 different places in a single HTML page. That statistics div
has a 6 row long list.
My question is this..
Is it faster to use:
<div class="statistics"></div>
and then use jquery like this:
$( ".statistics" ).append( $(<ul><li>content</li><li>content</li><li>content</li><li>content</li><li>content</li><li>content</li></ul>'));
...rather than copy/paste the code in those 5 different places ?
If you want faster and efficient with use of jQuery we can use it with native js
$('.statistics').each(function(i) {
var newDOM = document.createElement('ul');
newDOM.innerHTML = '<li>content</li><li>content</li><li>content</li><li>content</li><li>content</li><li>content</li>';
this[i].appendChild(newDOM);
});
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments