JS: Detecting wrapped inline elements?

I have an undefined number of inline elements. Now, depending on the width of the browser, some elements, of course, will be transferred to a new line. Is it possible to detect and highlight these lines of elements, or does dom just see one large line in it?

Thanks for the help!

EDIT: Trying to detect wrapped items using offset height (thanks Matchu). Wrapped items return the same value (total height of the item), like those found on the first line. Any reason why?

$('#content').children().each(function() {
       alert($(this)[0].offsetHeight); 
    });
+5
source share
3 answers

offsetHeight , . offsetHeight, , .

+12

element.getClientRects(), , , . Bowser .

+1

No, this is not possible directly. You can only try to measure the width of each element, calculate the position and process those that do not fit.

-2
source

All Articles