jquery,html , Is appending the html faster than pasting it multiple times?
Is appending the html faster than pasting it multiple times?
Question:
Tag: jquery,html
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 ?
Answer:
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);
});
Related:
javascript,jquery,date
I have two long dates value. For Ex: 1433097000000 1434479400000 Here i have to find the days between these two by jquery For Ex: 15/06/2015 - 22/06/2015 If it is more than 5 days, I want to get from is 15/06/2016, to is 19/06/2015. It is based on long values...
html,css,css-shapes
This question already has an answer here: CSS triangle custom border color 2 answers How can i create a div with the form of a pencil, just like this: It seems a basic thing but im trying to do it since some time ago and still couldnt do it....
javascript,php,jquery,html,css3
I have a single page website and need to link the navigation to IDs in the page. I have three links: "About us", "Our Project", "contact". So if user clicks on "About ", the About section will be displayed, same with other links. Inside Our project there is Two buttons...