106 jquery
我有这个无序列表
<ul>
<li>two</li>
<li>three</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
有没有办法可以在无序列表前加上这样的结果?
<ul>
<li>ONE</li>
<li>two</li>
<li>three</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
注意,"ONE"被添加到列表的FRONT/TOP中.
使用prepend instread of append
<h2>Greetings</h2>
<div class="container">
<div class="inner">Hello</div>
<div class="inner">Goodbye</div>
</div>
$('.container').prepend('<p>Test</p>');
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请参阅http://api.jquery.com/prepend/.