最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - No Line Break With jQuery .append() - Stack Overflow

programmeradmin11浏览0评论

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>;/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?

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./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?

Share Improve this question asked Jun 26, 2011 at 3:22 Nathan CamposNathan Campos 29.5k62 gold badges200 silver badges307 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

Try changing the div to a span

发布评论

评论列表(0)

  1. 暂无评论