如何删除< li>来自< ul>由ID?
问题描述:
我有:
<ul id="ulId">
<li id="firstli">
</li>
<li id="secondli">
</li>
</ul>
并且我正在尝试删除secondli
.
这是我根据一些阅读尝试过的.
This is what I have tried based on some reading.
$('#ulId secondli').remove();
和
$('#ulId > secondli').remove();
,但是这两种方法不起作用.有什么建议吗?
but these 2 methods did not work. Any suggestions?
答
尝试一下:
$('#secondli').remove();
在jQuery中,您引用的元素的ID前面带有#
.请参见 http://api.jquery.com/id-selector/
In jQuery, you refer to the ID of an element with a #
in front of it. See http://api.jquery.com/id-selector/