var a = document.getElementById('div1').getElementsByTagName('a'), i = a.length, wsum = 0; while (i) wsum += a[--i].offsetWidth; alert(wsum);