webmonkey237
webmonkey237

Reputation: 379

jQuery custom slider query

I had someone from this site help me out with a slider problem I was having and I just need someone to help me with the final piece of the puzzle.

This is the Fiddle http://jsfiddle.net/gajjuthechamp/vrqdh/2/

At the moment when you click on the "thumbnail" the content appears in the main div above.

I need the divs/thumbnails under "extraContent" have it's own unique content div under "mainContent".

Hope this makes sense.

Thanks

jQuery:

$(function(){
  $("#parent").on("click", ".extraContent div", function(){
       newHtml=$(this).html();
       $("#parent").find(".mainContent p").fadeOut(1000,function(){
              $(this).parent().html(newHtml);
              $(this).parent().fadeIn(1000);
       });
    });
});

HTML:

<div id="parent">
    <div class="mainContent"> <p>This is the default Text</p></div>
    <div class="extraContent">
        <div><p>test and Image Goes hear for 1 div</p></div>
        <div><p>test and Image Goes hear for 2 div</p></div>
        <div><p>test and Image Goes hear for 3 div</p></div>
        <div><p>test and Image Goes hear for 4 div</p></div>
    </div>
</div>

CSS:

#parent { width:400px; margin:auto}
.mainContent { width:430px; height:300px; border:1px solid #000;padding:5px; }
.extraContent {overflow:auto; width:450px;}
.extraContent div{float:left; width:90px; height:90px; border:1px solid #00F; margin:5px; padding:5px }
.extraContent div:hover { border:1px solid #0F0;cursor:pointer }

Upvotes: 2

Views: 252

Answers (1)

Roko C. Buljan
Roko C. Buljan

Reputation: 205987

jsFiddle demo

HTML:

<div id="parent">
    <div class="mainContent">
        <div class="cont"> Content 1....</div>
        <div class="cont"> Content 2....</div>
        <div class="cont"> Content 3....</div>
        <div class="cont"> Content 4....</div>  
    </div>
    <div class="extraContent">
        <div><p>1 Custom content here</p></div>
        <div><p>2 Custom content here</p></div>
        <div><p>3 Custom content here</p></div>
        <div><p>4 Custom content here</p></div>
    </div>
</div>

ADDED CSS:

.cont{position:absolute;}

jQuery:

$(function(){
  $('.cont:gt(0)').hide();
  $("#parent").on("click", ".extraContent div", function(){
       var ind = $(this).index();
       $("#parent").find(".cont").stop().fadeTo(600,0,function(){
           $('#parent').find('.cont').eq(ind).stop().fadeTo(300,1);
       });
    });
});

Upvotes: 1

Related Questions