javascript - Insert div on next line when element is clicked -


i trying make similar find in google images. when picture clicked, div image appears on next line on other images under clicked one.

i have set of divs float:left , position:relative. have different widths. when click on div want new full width div appear on next line. divs under clicked 1 should bushed down under full width one.

i tried looping through divs , compare position of divs clicked 1 this:

    $(".wrapper").on("click", ".testdivs", function () {         var thistop = $(this).position().top;         $(".testdivs").each(function(i, obj) {             var othertop = $(obj).position().top;             if(thistop < othertop){                 $(".fullwidthdiv").insertbefore(obj);                 return;             }         });     }); 

this doesn't work , don't know how should this. tips/solutions?

this requires lot of information explain. i'd rather suggest reading blog post on topic.hope you.

https://www.sitepoint.com/recreating-google-images-search-layout-css/


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -