2010-12-26 7 views

답변

9

이것은? 당신은 단지 아이들 요소를 원하는 경우

var width = 0; 
$('selector > *').each(function() { width += $(this).width(); }); 

jsFiddle example

+0

하위 요소에만 국한되지 않습니다. – user113716

5

, 이렇게 :

예 :http://jsfiddle.net/PV2dR/

var t=0; 
$('#parent > *').width(function(i,w){t+=w;}); 

아니면 같은 결과로이 작업을 수행 할 수 있습니다

var t=0; 
$('#parent').children().width(function(i,w){t+=w;}); 
관련 문제