Quote:
Originally Posted by Old Pedant
Well, I *did* say "for example" about createDocumentFragment.
Okay, okay...I'll show my scheme. It's not clever. It's not better. It's just simple. Back later.
But I just noticed this in your code:
Code:
// grab 3 different items:
for (var $i = 0; $i < 3; $i++) {
frag.appendChild(items[Math.floor(Math.random() * items.length)]);
}
??? How does that answer my prior objection that you might get the same <li> all 3 times? And you will surely get the same item twice more often than would make the user happy. What am I missing?
|
when you append an element to the fragment, it disappears from the nodeList...
remember, unlike arrays of elements, nodeLists from element.getXXXbyXXX() methods are live.
the other routines i imagined were much more complex, which is why i was curious about what you had in mind.