I've been trying to get this working for the past hour and I'm completely stuck; the below only returns the width of the first child, the rest of the children return a width of "0" when logged.
JS
function getWidth() {
var $item = $('#image-inner-wrap .project-item'),
width = 0;
$item.each(function() {
width += $(this).width();
});
return width;
}
HTML The last three elements are imgs:
<section id="image-wrap">
<div id="image-inner-wrap">
<div id="client-title" class="project-item">
<h1>Ink</h1>
</div>
<img class="project-item" src="https://m1.behance.net/rendition/modules/159185859/hd/e73f3ac14e59899ad4488cfad44a5af8.jpg">
<img class="project-item" src="https://m1.behance.net/rendition/modules/159183497/hd/d93ad4f39d67c0627e33e88ac4a417c6.jpg">
<img class="project-item" src="https://m1.behance.net/rendition/modules/159183473/hd/6397ae0edc996e6db3e85e824b21e79e.jpg">
</div>
</section>
CSS
#image-wrap {
position: absolute;
bottom: 0;
width: 100%;
height: 90%;
padding: 60px 60px 60px;
box-sizing: border-box;
z-index: 10;
}
#client-title,
#image-wrap img {
float: left;
height: 100%;
margin-right: 60px;
}
#client-title {
display: table;
width: 12%;
}
#client-title h1 {
display: table-cell;
vertical-align: middle;
font-size: 60px;
text-align: center;
}
#image-inner-wrap {
height: 100%;
}
I originally thought it could be because the images aren't being loaded fast enough, but even with a setTimeout wrapping the each function it's not working. Any pointers?