Can you select all divs of a class that flow to the next line?

css, html, javascript, jquery

Solution

As you say your self, there is no way to do that with CSS (that I know of). However, it can be done quite easily with jQuery.

One way to do it would be to use a combination of filter and offset to only keep the elements with higher top offset than the others (those who doesn't fit on the first row).

var $elm = $(".yourSelector"); // Use your selector here
var $secondRowElms = $elm.filter(function () {
   // Compare each item with the first item, to see if it has higher offset
   return ($elm.first().offset().top < $(this).offset().top);        
});

Here is a demo as well: http://jsfiddle.net/8ppJP/1/

Problem

So I've got 7 to 12 divs all of the same style which are floated left. I am looking for a css selector for all the ones that flow to a second row. I am pretty sure this is not possible with standard css, but I am wondering if anyone knows any jQuery or other tricks that could get this done. Thanks a bunch!

Original source