Cec*_*ore 1 jquery image function html-lists
我有一个无序列表,其中列表项包含图像的链接.我的代码当前遍历列表项,获取href,在div中创建一个新的图像容器banner-holder并添加src属性.
我想要做的是跳过第一个列表项,因为我已经拥有该图像banner-holder,我不想添加它两次.
谢谢.
$('li').each(function ()
{
var bigImage = $(this).find('a.main-img').attr('href');
$('<img/>').attr('src', bigImage).appendTo('#banner-holder');
});
Run Code Online (Sandbox Code Playgroud)
$('ul li').not(':first-child').each(function ()
{
var bigImage = $(this).find('a.main-img').attr('href');
$('<img/>').attr('src', bigImage).appendTo('#banner-holder');
});
Run Code Online (Sandbox Code Playgroud)