Using jQuery how can you select all elements but the last?
<div class='elem'>1</div>
<div class='elem'>2</div>
<div class='elem'>3</div>
For example I want hide div's 1 and 2, but keep three.
$("div.elem:not(:last)").hide();
要么
$("div.elem").not(":last").hide();
您可以按照下面定义的元素的nth-child隐藏。
$("div.elem:not(:nth-child(3))").hide();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.