我试图简单地删除 中的所有嵌套li
元素ul
,但它不起作用。为什么这个片段不起作用?我错过了什么?
html
<ul id="myul">
</ul>
<br/>
<button onclick="add();">add</button><br/>
<button onclick="remAll();">remove all</button>
js
function add()
{
$('#myul').append('<li>hello world</li>');
}
function remAll()
{
$('#myul').remove('li');
}