![](/img/trans.png)
[英]What's the best way to select an element between one element and one of its ancestor using jQuery
[英]What is the best way to select an element if the element's index is over 3?
偽代碼
$("#cool ul li.active:eq( > 3)") { // selector if the active li is over 3
$('#cool ul').animate({right: '+=984'},0);
};
如果 li 超過 3,select 的最佳方法是什么?
if ($("#cool li:gt(3)").hasClass('active')) {
$('#cool ul').animate({right: '+=984'},0);
};
編輯:第一次正確,以為我錯了,弄錯了,應該再次糾正:P
if($("#cool ul li:gt(2)").filter('.active').length === 1) {
$('#cool ul').animate({right: '+=984'},0);
};
編輯:更新代碼以假設 1 .active
li
編輯 2:暫時忘記:gt()
使用基於 0 的索引
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.