Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要使用 jQuery 从 div 内的列表中删除所有项目
问题是 ul 没有类或 id 但 div 有一个 id。
<div id="myDiv"> <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> </ul> </div>
你似乎想要
$('#myDiv ul li').remove();
使用.empty()
$('#myDiv > ul').empty();