Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.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滑动/向下循环?_Jquery_Loops_Html_Slidedown_Slideup - Fatal编程技术网

JQuery滑动/向下循环?

JQuery滑动/向下循环?,jquery,loops,html,slidedown,slideup,Jquery,Loops,Html,Slidedown,Slideup,我错在哪里? 只希望在鼠标离开该区域时.ex向上滑动。。但它似乎在循环,然后向上滑动 $("div.case").mouseover(function () { var id = $(this).attr("id"); $(this).css("opacity", "1").css("filter", "alpha(opacity=100)"); $(".ex"+id).slideDown(500); }); $("div.case").mouseout(function () { var

我错在哪里?

只希望在鼠标离开该区域时.ex向上滑动。。但它似乎在循环,然后向上滑动

 $("div.case").mouseover(function () {
var id = $(this).attr("id");
$(this).css("opacity", "1").css("filter", "alpha(opacity=100)");
$(".ex"+id).slideDown(500);
});

$("div.case").mouseout(function () {
var id = $(this).attr("id");
$(this).css("opacity", "0.4").css("filter", "alpha(opacity=40)");
$(".ex"+id).slideUp(500);
});

有人知道可能是什么问题吗?

尝试使用
mouseenter
mouseleave

如果在具有绑定事件的元素中从每个子元素移动到另一个子元素,则也会触发事件
mouseover
mouseout


您还可以使用
鼠标悬停
,它是
鼠标指针
鼠标悬停
的别名。这可能是执行此功能的更好方法:

$('.case').hover(function(){
    var id = $(this).attr('id');
    $(this).css('opacity':'1','filter':'alpha(opacity=100)');
    $('.ex'+id).slideDown(500);
},
function(){
    var id = $(this).attr('id');
    $(this).css('opacity':'0.4','filter':'alpha(opacity=40)');
    $('.ex'+id).slideUp(500);
});
悬停方法使用两个函数。第一个是初始悬停函数,第二个是悬停退出回调函数。我猜的
.ex
元素是以这种方式生成的<代码>0.ex0.ex1.ex2。如果是这样的话,你的功能应该可以发挥作用。如果
.ex
元素位于
.case
中,并且有多个
.case
可以使用此选择器:

$('.ex',this)
如果您有此元素的列表,则可以使用取消id的方法并使用
:eq()
索引选择器:

$('.ex:eq('+id+')')


基本上,
div.case
元素将在
ex
div向下滚动=>后变得更高,如果您的鼠标靠近该区域,您仍然将
div.case
 $("div.case img").mouseover(function () {
   ....
 }

  $("div.case img").mouseout(function () {
   ....
 }