Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.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_Html - Fatal编程技术网

Javascript 淡出当前元素淡出下一个元素并反转

Javascript 淡出当前元素淡出下一个元素并反转,javascript,jquery,html,Javascript,Jquery,Html,这件事我需要一些帮助。我有一个包含很多图像的div: <a href="#" id="trigger_next">Next</a> <a href="#" id="trigger_prev">Prev</a> <div id="image_wrapper"> <img id="image1" class="images" src="image1.jpg"/> <img id="image2" class="i

这件事我需要一些帮助。我有一个包含很多图像的div:

<a href="#" id="trigger_next">Next</a>
<a href="#" id="trigger_prev">Prev</a>

<div id="image_wrapper">
  <img id="image1" class="images" src="image1.jpg"/>
  <img id="image2" class="images" style="display: none;" src="image2.jpg"/>
  <img id="image3" class="images" style="display: none;" src="image3.jpg"/>
  <img id="image4" class="images" style="display: none;" src="image4.jpg"/>
  <img id="image5" class="images" style="display: none;" src="image5.jpg"/>
  <img id="image6" class="images" style="display: none;" src="image6.jpg"/>
</div>
找出当前和下一个图像并将其放入工作函数的最佳方法是什么


感谢CSS中的

  .images{
    display:none;
    }
$(document).ready(function(){
$("#image_wrapper").find("img:first").show();

//for next section

$('#next').click(function() {
var visible=$("#image_wrapper img:visible"); //select visible image then do action
    visible.fadeOut();
    visible.next().fadeIn();
        });

//for previous section
 $('#previousid').click(function() {
   var visible=$("#image_wrapper img:visible");
    visible.fadeOut();
    visible.prev().fadeIn();
     });

});
在JS中

  .images{
    display:none;
    }
$(document).ready(function(){
$("#image_wrapper").find("img:first").show();

//for next section

$('#next').click(function() {
var visible=$("#image_wrapper img:visible"); //select visible image then do action
    visible.fadeOut();
    visible.next().fadeIn();
        });

//for previous section
 $('#previousid').click(function() {
   var visible=$("#image_wrapper img:visible");
    visible.fadeOut();
    visible.prev().fadeIn();
     });

});

参考

以及之前的?你的情况不是这样吗是否会淡出?当我制作一个
时。单击
#next
上的()
,然后用
$(此)
引用,它会淡出
#next
而不是显示的当前图像。