//不建议的做法
var browserList = ["Internet Explorer", "Mozilla Firefox", "Safari", "Chrome", "Opera"];
$.each(browserList, function (index,value) {
$('
').text(value).appendTo($('ul').eq(0));
})
//好的做法NO1
var browserList = ["Internet Explorer", "Mozilla Firefox", "Safari", "Chrome", "Opera"];
var myHTML = '';
$.each(browserList, function (index, value) {
myHTML += '' + value + '';
})
$('ul').eq(0).html(myHTML);
//好的作法NO2
var frag = document.createDocumentFragment();
var browserList = ["Internet Explorer", "Mozilla Firefox", "Safari", "Chrome", "Opera"];
$.each(browserList, function (index, value) {
var li = document.createElement("li");
li.textContent = value;
frag.appendChild(li);
})
$('ul').eq(0).append($(frag));