我有一个 ul 类 .answers。
如何定位该列表中的最后一个 li?
我有:
$(this).parent().children(".answers li:last")
这针对答案很好:
$(this).parent().children(".answers');
只是最后一点有问题
HTML
<div class="control-group">
<label class="control-label">Answers:</label>
<div class="controls">
<ul class="answers">
<li class="answer">
<input class="input-xxlarge answerInput" type="text" placeholder="Answer A" name="answer">
<button type="button" class="btn btn-inverse deleteAnswerBtn">x</button>
</li>
<li class="answer">
<input class="input-xxlarge answerInput" type="text" placeholder="Answer A" name="answer">
<button type="button" class="btn btn-inverse deleteAnswerBtn">x</button>
</li>
</ul>
<button type="button" class="btn addAnswerBtn">+</button>
</div>
</div>