Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery next()未按预期工作_Jquery_Next - Fatal编程技术网

jQuery next()未按预期工作

jQuery next()未按预期工作,jquery,next,Jquery,Next,我有一组链接图像,我想每3秒循环一次,但每次只显示一个: # some django template code: <div id="featured-prints" class="featured-promo"> {% for p in promo_prints %} <a href="{% url 'print_order_with' p.id %}"> <img class="featured-print" src="{{ ME

我有一组链接图像,我想每3秒循环一次,但每次只显示一个:

# some django template code:
<div id="featured-prints" class="featured-promo">
    {% for p in promo_prints %}
    <a href="{% url 'print_order_with' p.id %}">
        <img class="featured-print" src="{{ MEDIA_URL }}{{ p.id }}_{{ THUMBNAIL_SIZE }}.png" alt="{{ p.body }}" />
    </a>
    {% endfor %}
</div>

# the JS to cycle through:

$(function(){
    $('.featured-promo a:gt(0)').hide();
    setInterval(function(){
        $('.featured-promo :first-child')
        .hide()
        .next('a')
        .fadeIn(2000)
        .end()
        .appendTo('.featured-promo');
}, 1000);
#一些django模板代码:
{promo_prints%}
{%endfor%}
#要循环通过的JS:
$(函数(){
$('.promo a:gt(0)').hide();
setInterval(函数(){
$(“.特色宣传片:第一个孩子”)
.hide()
.next('a'))
fadeIn先生(2000年)
(完)
.appendTo(“.特色宣传片”);
}, 1000);
我最近在img周围添加了
,现在Javascript不起作用了;它不能
fadeIn()
下一个链接图像。我尝试了几种变体,包括将“a”传递到
next()
,以及“a img”,但似乎没有任何效果。我还尝试将
parent()
链接到
hide())
功能,仍然没有骰子

有什么建议吗

$(function(){
    $('.featured-promo a:gt(0)').hide();
    setInterval(function(){
    $('.featured-promo :first-child')
    .hide()
    .find('a')
    .fadeIn(2000)
    .end()
    .appendTo('.featured-promo');
}, 1000);
尝试查找而不是下一个

尝试查找而不是下一个

尝试查找而不是下一个

尝试查找而不是下一步

在隐藏()之后使用end():

在hide()之后使用end():

在hide()之后使用end():

在hide()之后使用end():

试试这个:

$(function(){
    $('.featured-promo a:gt(0)').hide();
    setInterval(function(){
        $('.featured-promo').children('a .featured-print').eq(1).parent()
        .hide()
        .next('a')
        .fadeIn(2000)
        .end()
        .appendTo('.featured-prints');
}, 1000);
试试这个:

$(function(){
    $('.featured-promo a:gt(0)').hide();
    setInterval(function(){
        $('.featured-promo').children('a .featured-print').eq(1).parent()
        .hide()
        .next('a')
        .fadeIn(2000)
        .end()
        .appendTo('.featured-prints');
}, 1000);
试试这个:

$(function(){
    $('.featured-promo a:gt(0)').hide();
    setInterval(function(){
        $('.featured-promo').children('a .featured-print').eq(1).parent()
        .hide()
        .next('a')
        .fadeIn(2000)
        .end()
        .appendTo('.featured-prints');
}, 1000);
试试这个:

$(function(){
    $('.featured-promo a:gt(0)').hide();
    setInterval(function(){
        $('.featured-promo').children('a .featured-print').eq(1).parent()
        .hide()
        .next('a')
        .fadeIn(2000)
        .end()
        .appendTo('.featured-prints');
}, 1000);
试着改变

$('.featured-promo :first-child')
致:

如果没有
,它会下降到每一个级别。因此它会找到
特色宣传片的第一个子级(第一个
a
),以及每个
a
(每个
img
)的第一个子级。它隐藏所有这些,然后只在下一个
a
中淡入淡出。
img
标记保持隐藏,因为没有任何东西会淡入淡出

选择器中的
意味着只将下一部分与直接子项匹配,而不是所有子项匹配。

尝试更改

$('.featured-promo :first-child')
致:

如果没有
,它会下降到每一个级别。因此它会找到
特色宣传片的第一个子级(第一个
a
),以及每个
a
(每个
img
)的第一个子级。它隐藏所有这些,然后只在下一个
a
中淡入淡出。
img
标记保持隐藏,因为没有任何东西会淡入淡出

选择器中的
意味着只将下一部分与直接子项匹配,而不是所有子项匹配。

尝试更改

$('.featured-promo :first-child')
致:

如果没有
,它会下降到每一个级别。因此它会找到
特色宣传片的第一个子级(第一个
a
),以及每个
a
(每个
img
)的第一个子级。它隐藏所有这些,然后只在下一个
a
中淡入淡出。
img
标记保持隐藏,因为没有任何东西会淡入淡出

选择器中的
意味着只将下一部分与直接子项匹配,而不是所有子项匹配。

尝试更改

$('.featured-promo :first-child')
致:

如果没有
,它会下降到每一个级别。因此它会找到
特色宣传片的第一个子级(第一个
a
),以及每个
a
(每个
img
)的第一个子级。它隐藏所有这些,然后只在下一个
a
中淡入淡出。
img
标记保持隐藏,因为没有任何东西会淡入淡出

选择器中的
意味着只将下一部分与直接子代匹配,而不是所有子代匹配。

错误就在那里

$(function(){
  $('.featured-promo a:gt(0)').hide();
   setInterval(function(){
     $('.featured-promo :first-child')// here
     .hide()
     .next('a')
     .fadeIn(2000)
     .end()
     .appendTo('.featured-promo');// no need to append as the for loop is already appending the anchors to the featured-promo.
   }, 1000);
)};
您正在调用
.featured promo
上的
.next('a')
第一个孩子,它不是
.featured promo
的兄弟姐妹,但它是孩子。
elementA.next()
用于获取同级(元素a之后的元素,即元素B)

要得到另一个
a
s',您应该这样写

$(function(){
  var index = 0;
  var total_a = $('.featured-promo a').length;
   setInterval(function(){
     $('.featured-promo a:gt(' + index + ')')
     .hide()
     .next('a')
     .fadeIn(2000);
     index = (index < total_a) ? index + 1 : 0;// will increment if number of a is greater than index else 0 and continue like a slider..
   }, 2000);// better use 2000 ms as you're using 2000ms in the `fadeIn()`
 });
$(函数(){
var指数=0;
var total_a=$('.特色促销a')。长度;
setInterval(函数(){
$('.特色宣传片a:gt('+index+'))
.hide()
.next('a'))
fadeIn先生(2000年);
index=(index
错误就在那里

$(function(){
  $('.featured-promo a:gt(0)').hide();
   setInterval(function(){
     $('.featured-promo :first-child')// here
     .hide()
     .next('a')
     .fadeIn(2000)
     .end()
     .appendTo('.featured-promo');// no need to append as the for loop is already appending the anchors to the featured-promo.
   }, 1000);
)};
您正在调用
.featured promo
上的
.next('a')
第一个孩子,它不是
.featured promo
的兄弟姐妹,但它是孩子。
elementA.next()
用于获取同级(元素a之后的元素,即元素B)

要得到另一个
a
s',您应该这样写

$(function(){
  var index = 0;
  var total_a = $('.featured-promo a').length;
   setInterval(function(){
     $('.featured-promo a:gt(' + index + ')')
     .hide()
     .next('a')
     .fadeIn(2000);
     index = (index < total_a) ? index + 1 : 0;// will increment if number of a is greater than index else 0 and continue like a slider..
   }, 2000);// better use 2000 ms as you're using 2000ms in the `fadeIn()`
 });
$(函数(){
var指数=0;
var total_a=$('.特色促销a')。长度;
setInterval(函数(){
$('.特色宣传片a:gt('+index+'))
.hide()
.next('a'))
fadeIn先生(2000年);
index=(index
错误就在那里

$(function(){
  $('.featured-promo a:gt(0)').hide();
   setInterval(function(){
     $('.featured-promo :first-child')// here
     .hide()
     .next('a')
     .fadeIn(2000)
     .end()
     .appendTo('.featured-promo');// no need to append as the for loop is already appending the anchors to the featured-promo.
   }, 1000);
)};
您正在调用
.featured promo
上的
.next('a')
第一个孩子,它不是
.featured promo
的兄弟姐妹,但它是孩子。
elementA.next()
用于获取同级(元素a之后的元素,即元素B)

要得到另一个
a
s',您应该这样写

$(function(){
  var index = 0;
  var total_a = $('.featured-promo a').length;
   setInterval(function(){
     $('.featured-promo a:gt(' + index + ')')
     .hide()
     .next('a')
     .fadeIn(2000);
     index = (index < total_a) ? index + 1 : 0;// will increment if number of a is greater than index else 0 and continue like a slider..
   }, 2000);// better use 2000 ms as you're using 2000ms in the `fadeIn()`
 });
$(函数(){
var指数=0;
var total_a=$('.特色促销a')。长度;
setInterval(函数(){
$('.特色宣传片a:gt('+index+'))
.hide()
.next('a'))
fadeIn先生(2000年);
index=(index
错误就在那里

$(function(){
  $('.featured-promo a:gt(0)').hide();
   setInterval(function(){
     $('.featured-promo :first-child')// here
     .hide()
     .next('a')
     .fadeIn(2000)
     .end()
     .appendTo('.featured-promo');// no need to append as the for loop is already appending the anchors to the featured-promo.
   }, 1000);
)};
您正在调用
.featured promo
上的
.next('a')
第一个孩子,它不是
.featured promo
的兄弟姐妹,但它是孩子。
elementA.next()
用于获取同级(元素a之后的元素,即元素B)

要获取另一个
a