我正在看教程中的一些代碼來創建一個輪播菜單,並注意到沒有父母的父子選擇器。之前從來沒有見過這樣的事情,並且對它實際上在做什麼感到困惑。沒有父母的jQuery的兒童選擇器
見下面的代碼:
var $wrapper = $('> div', this).css('overflow', 'hidden'),
$slider = $wrapper.find('> ul'),
$items = $slider.find('> li'),
$single = $items.filter(':first'),
singleWidth = $single.outerWidth(),
visible = Math.ceil($wrapper.innerWidth()/singleWidth), // note: doesn't include padding or border
currentPage = 1,
pages = Math.ceil($items.length/visible);
教程這裏:http://jqueryfordesigners.com/jquery-infinite-carousel/