Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.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
Javascript 如何通过单击此框来显示仅活动框的图标_Javascript_Jquery - Fatal编程技术网

Javascript 如何通过单击此框来显示仅活动框的图标

Javascript 如何通过单击此框来显示仅活动框的图标,javascript,jquery,Javascript,Jquery,请看图片,我必须通过点击框来显示箭头图标,我已经尝试过了,但现在它显示在所有框中 如何为每个框单独显示? 这是我的密码 $('.date-box').click(function(){ $('.date-box').removeClass('active-item'); $(this).addClass('active-item'); $('.next-icon').show(); }); 您需要指定只希望在当前单击的框中显示图标,就像在活动类中一样。 示例:$

请看图片,我必须通过点击框来显示箭头图标,我已经尝试过了,但现在它显示在所有框中

如何为每个框单独显示?

这是我的密码

 $('.date-box').click(function(){
    $('.date-box').removeClass('active-item');
    $(this).addClass('active-item');
    $('.next-icon').show();
  });

您需要指定只希望在当前单击的框中显示图标,就像在活动类中一样。 示例:
$('.next icon',this.show()

$('.next icon')。show()
将显示具有类
下一个图标的所有元素。您需要指定要在哪个范围内查找该类

如果
下一个图标
类位于
日期框内

$('.date-box').click(function(){
    $('.date-box').removeClass('active-item');
    $(this).addClass('active-item');

    // Hiding all and showing just the current one
    $('.next-icon').hide();
    $(this).find('.next-icon').show();
});

请同时共享您的html..
$(this).find('.next icon').show()仅显示curren元素的图标尝试此,$(this).closest('.next icon').show()@naresh如果解决了您的问题,请标记答案:)