2010-05-15 3 views
2

"사과"등급의 DIV 무리와 "오렌지색"등급의 DIV 무리가 있다고 가정 해 봅시다.jQuery : 페이지의 모든 요소 위치를 재설정하는 방법은 무엇입니까?

이러한 모든 DIV에는 다양한 위치가 있지만 jQuery 함수를 사용하여 부모 컨테이너에 상대적인 새 위치를 다시로드하지 않고 페이지에 라이브로 할당하려고합니다.

예를 들어, 페이지를 다시로드하지 않고 상위 컨테이너에 상대적인 "최상위"값인 "apple"클래스의 모든 DIV를 "200px"로 설정하려면 어떻게해야합니까?

감사합니다.

답변

3
var $apples = $('.apple'); // caching your elements 

$apples.parent().css('position', 'relative'); // setting the parent to a relative position 

$apples.css('position', 'absolute') // setting an absolute position, relative to the parent 
     .css('top', '200px'); // setting the top position 
관련 문제