有人可以借给我一个手
我有这个无序的名单
<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>");
解决方法
如果要在最后添加使用
append()
方法而不是
prepend()
:
$('#nav ul').append('<li class="last_link"><a href="https://projects.parc-services.com" target="blank">Login</a></li>');
或者我喜欢:
$('#nav ul').append( $('<li/>',{ 'class': 'last_link',html: $('<a/>',{ href: 'https://projects.parc-services.com',target: '_blank',text: 'Login' }) }) );