views:

57

answers:

2

This could be a simple thing im sure...

Im trying to get the fade to slide:

$slides.eq($btns.index(this)).fadeIn().siblings().hide();

At the moment it works great with fade, i just need this line tweaked to slide, ive done the obvious but i must be doing something with the syntax as it doesnt work.

Cheers in advance!

//added

var
$btns = $('.btns a'),
$slides = $('.slides > div');

$btns.click(function(){
  $(this).addClass('current')
  $(this).parent().siblings().find('a').removeClass('current');
  $slides.eq($btns.index(this)).fadeIn(function(){ slideIn }).siblings().hide();
  return false;
});
$btns.first().click();

  <div class="slides">
    <div>Slide 1</div>
    <div>Slide 2</div>
    <div>Slide 3</div>
    <div>Slide 4</div>
    <div>Slide 5</div>
    <div>Slide 6</div>
  </div>

  <ul class="btns">
    <li class="one"><a href="#">1</a></li>
    <li class="two"><a href="#">2</a></li>
    <li class="three"><a href="#">3</a></li>
    <li class="four"><a href="#">4</a></li>
    <li class="five"><a href="#">5</a></li>
    <li class="six"><a href="#">6</a></li>
  </ul>
A: 

inside the fadeIn() do the slide. so something like fadeIn(function(){ slideIn })...

griegs
btw: this all works in firefox but i have had dissapointing results in IE. IE tends to ignore the animation and simply renders everything at the end. that was in the previous version of jQuery tho
griegs
Hey thanks, do you mean like this? $slides.eq($btns.index(this)).fadeIn(function(){ slideIn }).siblings().hide();
Andy
Not sure about a lot of that code actually. Seems a little long. Could you post the html you are trying to hide and slide as i think the code can be a lot simpler.
griegs
I amended my initial post. Thanks for your help griegs
Andy
+3  A: 

If you want a normal slide, use .slideUp() and .slideDown(), like this:

$slides.eq($btns.index(this)).slideDown().siblings().slideUp();

You can view a demo here


If instead you want a fade + slide type of effect, pass a speed parameter to .hide() and .show(), like this:

$slides.eq($btns.index(this)).show('slow').siblings().hide('slow');

You can test that effect here

Nick Craver
@Nick I think he wants to slide and fade at the same time.
griegs
@griegs - The title says "instead of"...so I provided both options, the second option has a fade/slide combo effect, give it a try :)
Nick Craver
Thanks Nick...perfect...and thanks griegs for your initial help
Andy