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

Jquery 如何正确使用本例中的每个函数?

Jquery 如何正确使用本例中的每个函数?,jquery,function,each,Jquery,Function,Each,正在编写这段代码,我被卡住了。。我试图实现的是,当selection div中有2个以上的选项时,覆盖消息的底部位置从10px(在CSS中定义)移动到90px(在jQuery中定义)。问题是它应用于所有覆盖消息(90px),即使当我记录结果时,我得到2、3和4作为单独的结果。为什么不将结果分别应用于每个包装器div?这不是每个函数所做的,应用于每个单独的函数吗 谢谢 演示: 代码: $('.overlay_message')选择所有覆盖消息。您想要元素中的一个: $(this).find(".o

正在编写这段代码,我被卡住了。。我试图实现的是,当selection div中有2个以上的选项时,覆盖消息的底部位置从10px(在CSS中定义)移动到90px(在jQuery中定义)。问题是它应用于所有覆盖消息(90px),即使当我记录结果时,我得到2、3和4作为单独的结果。为什么不将结果分别应用于每个包装器div?这不是每个函数所做的,应用于每个单独的函数吗

谢谢

演示:

代码:

$('.overlay_message')
选择所有覆盖消息。您想要元素中的一个:

$(this).find(".overlay_message").css({bottom: 90});

您要选择正在操作的元素内的
.overlay\u消息

试试这个:

// Selects the 'overlay_message' div inside the current 'overlay' div
$(this).find(".overlay_message").css({bottom: 90});
与此相反:

// Selects all the 'overlay_message' div
$(".overlay_message").css({bottom: 90});

感谢您的澄清和解决方案搅拌机,工作,因为它确实应该!
// Selects the 'overlay_message' div inside the current 'overlay' div
$(this).find(".overlay_message").css({bottom: 90});
// Selects all the 'overlay_message' div
$(".overlay_message").css({bottom: 90});