Lets say we have this markup:
<div id="container">
<ul></ul>
<ul></ul>
</div>
Where the format of the <li> are such as:
<ul>
<li>
<span class="title">Title of the article</span>
<span class="date" data-value="[TIMESTAMP]">Pretty Date</span>
</li>
</ul>
What i need to do is:
-
If the viewport width is big enough: show both lists
-
If the viewport width is small: merge both lists by date
var min = 760; $(window).resize(function(){
var width = $(window).width();
if(width <= min){
merge_lists();
} });
where i have some trouble figuring out how to do it:
function merge_lists(){
/* shall i run 2 .each function and store it in an array, order by date (how?) and
regenerate a new list?
*/
}
I think you like something like this:
HTML:
jQuery:
DEMO