不建议的做法(多次渲染,消耗内存) var browserList = ["Internet Explorer", "Mozilla Firefox", "Safari", "Chrome", "Opera"];$.each(browserList, function (index,value) { $('ul').append($(' ').text(value));}) 好的方法NO1(创
var browserList = ["Internet Explorer", "Mozilla Firefox", "Safari", "Chrome", "Opera"]; $.each(browserList, function (index,value) { $('ul').append($('
var frag = document.createDocumentFragment(); var browserList = ["Internet Explorer", "Mozilla Firefox", "Safari", "Chrome", "Opera"]; $.each(browserList, function (index, value) { $(frag).append("
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').append($(frag));好的做法NO3(字符串拼接)
var browserList = ["Internet Explorer", "Mozilla Firefox", "Safari", "Chrome", "Opera"]; var myHTML = ''; $.each(browserList, function (index, value) { myHTML += '