Search code examples
jqueryhtmlimagestrip

image position swapping in a image strip through jquery


Not sure that i had structured the question right ,as i am not sure about the terminologies ,being new to web development. I have a page where there are four images in separate div, inside a parent div set as a strip of images with separate links. I want to swap their positions , say every 2 min through jquery may be randomly or in a cyclic order.

<div class="featurelisting-images">

     <div class="fl-list" id="fl1">
         <a href="/xyz.html" alt="xyz" title="xyz">
         <img src="/uploads/photo_1239.jpg"  title="xyz" alt="xyz" class=""/></a>                    
         <p class="title"><a href="/xyz.html" alt="xyz" title="xyz">xyz</a></p>
     </div>

     <div class="fl-list"    id="fl2">            
          <a href="/abc.html" alt="abc" title="abc">
          <img src="/uploads/photo_1357.jpg"  title="abc" alt="abc" class=""/></a>                    
          <p class="title"><a href="/abc.html" alt="abc" title="abc">abc</a></p>
     </div>

          // two more div elements like this...

</div>

I have got very limited knowledge of Jquery and am looking for a script to work for me. I tried Google it , but didn't got the right solution, may be because of wrong search terminology for this function. Tried some thing, but nothing worked.( See Fiddle ) I am trying using insert element in Jquery than changing all the attributes for each div element.


Solution

  • Put all the items in a single line using float:left

    After every two seconds, move the first one to the end.

    You can find a working example here.

    Please correct me if I am wrong or you want something else.