jQuery 追加到列表底部
有人可以帮我一下吗?
我有这个无序列表
<ul id="nav">
<li><a href="whatwedo.aspx">WHAT WE DO</a>
<ul>
<li><a href="development.aspx">Development</a></li>
<li><a href="marketassessment.aspx">MARKET ASSESSMENT AND CONCEPT DEVELOPMENT</a></li>
<li><a href="planning.aspx">DEVELOPMENT PLANNING AND OVERSIGHT</a></li>
<li><a href="preopening.aspx">PRE-OPENING OPERATIONAL SERVICES</a></li>
<li><a href="operations.aspx">OPERATIONAL MANAGEMENT SERVICES</a></li>
<li><a href="turnaround.aspx">TURNAROUND SERVICES</a></li>
<li><a href="news.aspx">NEWS</a></li>
</ul>
</li>
<li><a href="ourparks.aspx">OUR PARKS</a></li>
<li><a href="contact.aspx">CONTACT US</a></li> </ul>
,我想在列表底部添加一个新列表。
<li class="last_link"><a href="https://projects.parc-services.com" target="blank">Login</a></li>
我会通过做这样的事情来解决这个问题吗?
$("#nav ul").prepend("<li></li>");
Can someone lend me a hand
I have this unordered list
<ul id="nav">
<li><a href="whatwedo.aspx">WHAT WE DO</a>
<ul>
<li><a href="development.aspx">Development</a></li>
<li><a href="marketassessment.aspx">MARKET ASSESSMENT AND CONCEPT DEVELOPMENT</a></li>
<li><a href="planning.aspx">DEVELOPMENT PLANNING AND OVERSIGHT</a></li>
<li><a href="preopening.aspx">PRE-OPENING OPERATIONAL SERVICES</a></li>
<li><a href="operations.aspx">OPERATIONAL MANAGEMENT SERVICES</a></li>
<li><a href="turnaround.aspx">TURNAROUND SERVICES</a></li>
<li><a href="news.aspx">NEWS</a></li>
</ul>
</li>
<li><a href="ourparks.aspx">OUR PARKS</a></li>
<li><a href="contact.aspx">CONTACT US</a></li> </ul>
And I want to add a new list to the bottom of the list.
<li class="last_link"><a href="https://projects.parc-services.com" target="blank">Login</a></li>
Would I go about it by doing something like this?
$("#nav ul").prepend("<li></li>");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想在末尾添加,请使用
append()
方法而不是prepend()
:或者按照我的喜好:
If you want to add at the end use the
append()
method instead ofprepend()
:or as I prefer:
prepend
在元素的开头添加一些内容。append
用于在末尾添加一些内容。如果您想添加一个类或其他任何内容,您可以:
prepend
adds something at the beginning of an element.append
is used to add something at the end.And if you want to add a class, or anything else you can: