I have come across a puzzling situation with my code that involves determining the width of a block element. Here is an excerpt from the code snippet:
//get the largest block: if no block, apply to first block
var previous = $('.block-grid .block-group .block.block-lg');
var blocks = $('.block-grid .block-group .block');
blocks.last().css({'left': (previous.width() + previous.position().left), 'top': previous.position().top});
For some reason, when I refresh the page, the value returned by previous.width()
is 0 instead of the expected 400. This 400 represents the size of the largest block. Strangely, upon navigating directly to the URL of the page, the correct width value of 400 is returned. Can someone help me understand why refreshing the page would cause the width value to be incorrect? Any assistance would be greatly appreciated.