没有换行jQuery .append() [英] No Line Break With jQuery .append()

查看:327
本文介绍了没有换行jQuery .append()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 函数appendNav(xml){
$(xml).find(Nav)。each(function(){
$(#navBar)。append(< a id ='navItem'href ='+ $(this) (Link)。text()+'>+ $(this).attr(name)+< / a>);
$(#navBar) .append(< div class ='navItemSep'> |< / div>);
});

$(。navItemSep)。filter(:last)。remove();
}

并使用以下XML:

 <导航栏> 
< Nav name =Home>
< Link> index.html< / Link>
< /导航>
<导航名称=Twitter>
< Link> http://twitter.com/nathanpc< / Link>
< /导航>
< / Navbar>

问题在于我在多行而不是只有一行的情况下得到这个。我需要做什么才能使它在单行上输出?尝试更改 div 改为 span


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?

解决方案

Try changing the div to a span

这篇关于没有换行jQuery .append()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆