Here is some HTML code:
<ul class="list-ul">
<li style="width:10px; top: 0px"></li>
<li style="width:10px; top: 0px"></li>
<li style="width:10px; top: 5643px"></li>
<li style="width:10px; top: 56px"></li>
</ul>
This JavaScript function tries to sum the width of li elements with top = '0px':
var topValue = $('.list-ul li').css('top');
var totalWidth = 0;
if (topValue === '0px'){
$(this).each(function(){
totalWidth += $(this).outerWidth();
});
alert(totalWidth);
}
I am experiencing issues with this code, it doesn't seem to work as expected. Can anyone provide assistance?