问题
I'm parsing a XML using jQuery with the following code:
function appendNav(xml) {
$(xml).find("Nav").each(function() {
$("#navBar").append("<a id='navItem' href='" + $(this).find("Link").text() + "'>" + $(this).attr("name") + "</a>");
$("#navBar").append("<div class='navItemSep'> | </div>");
});
$(".navItemSep").filter(":last").remove();
}
And using the following XML:
<Navbar>
<Nav name="Home">
<Link>index.html</Link>
</Nav>
<Nav name="Twitter">
<Link>http://twitter.com/nathanpc</Link>
</Nav>
</Navbar>
The problem is that I'm getting this on multiple lines instead of only a single one. What I need to do to make it output this on a single line?
回答1:
Try changing the div
to a span
来源:https://stackoverflow.com/questions/6481941/no-line-break-with-jquery-append