Hi I cant seem to get a ul wrapped aournd a group of li. the wat i have it the closing tag does not get added to the end of the loop it puts it on one line link this <ul class="links"></ul>
//parse the AllLinks.xml file
function xmlParser(xml) {
$(xml).find("header").each(function(){
var headerlabel = $(this).attr("Label")
$("#allLinksContainer").append("<h5 class='heading'>" +headerlabel+ "</h5><ul class='links'>");
//get label content
$(this).find("link").each(function(){
var label = $(this).find('label').text()
var url = $(this).find("url").text()
var id = $(this).find("id").text()
$("#allLinksContainer").append("<li><a id='" +id+ "' href='" +url+ "'>" +label+ "</a></li>");
});//end links
$("#allLinksContainer").append("</ul>");
});//end header
}// close xmlParser function
Try this:
function xmlParser(xml) {
$(xml).find("header").each(function () {
var headerlabel = $(this).attr("Label") $("#allLinksContainer").append("<h5 class='heading'>" + headerlabel + "</h5>");
var ul = $("<ul class='links'></ul>");
$(this).find("link").each(function () {
var label = $(this).find('label').text();
var url = $(this).find("url").text();
var id = $(this).find("id").text();
ul.append("<li><a id='" + id + "' href='" + url + "'>" + label + "</a></li>");
});
$("#allLinksContainer").append(ul);
});
}
Or you could add all the LI items then select them with a new jQuery and use $("#allLinksContainer li").wrap("<ul></ul>")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.