Working on this code and am quite stuck.. What I'm trying to achieve is that when there are more then 2 selections in the selection div, the overlay message's bottom position moves from 10px (defined in CSS) to 90px (defined in the jQuery)。问题是它适用于所有覆盖消息(90px),即使当我记录结果时,我得到 2,3 和 4 作为单独的结果。为什么不将结果分别应用于每个包装器 div?这不是每个函数的作用,应用于每个单独的函数吗?
谢谢!
演示:http: //jsfiddle.net/6qD52/
代码:
$(".overlay").each(function() {
selection_number = $(this).parent().find(".selections").find(".selection").length;
console.log(selection_number);
if ((selection_number) > 2) {
$(".overlay_message").css({bottom: 90});
}
});