Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correction to Part III - Append New Content Outside Loop #23

Closed
JamesDunlop opened this issue Oct 11, 2011 · 1 comment
Closed

Correction to Part III - Append New Content Outside Loop #23

JamesDunlop opened this issue Oct 11, 2011 · 1 comment

Comments

@JamesDunlop
Copy link

Example using createDocumentFragment should be as follows:

// better: do this
var frag = document.createDocumentFragment();

$.each(myArray, function (i, item) {
    var newListItem = document.createElement("li");
    newListItem.textContent = item;
    frag.appendChild(newListItem);
});
$('#ballers')[0].appendChild(frag);
@gjohnson
Copy link
Contributor

Good catch, do note that textContent is not totally cross browser (I do not think it works in IE <= 8). Should use document.createTextNode instead.

@gjohnson gjohnson mentioned this issue Oct 15, 2011
gjohnson added a commit to gjohnson/web-learn-jquery-com that referenced this issue Oct 15, 2011
addyosmani added a commit that referenced this issue Oct 16, 2011
arthurvr pushed a commit to arthurvr/learn.jquery.com that referenced this issue Jan 4, 2015
arthurvr pushed a commit to arthurvr/learn.jquery.com that referenced this issue Jan 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants