开发者

jQuery fade content within a div

Hey there, so far i have this, it toggles my footer down and up, but i want the content of the footer to fade out and new content fade in when it's toggled down. I can't for the life of me work it out, please help! - thanks

$(document).ready(function() {
  $('#footertab').toggle(function() {
    $('#footer').animate({
      bottom: '-=120'
    }, 1000);
  },function() {
    $('#footer').animate({
      bottom: 开发者_开发技巧'+=120'
    }, 1000);
  })
});


Use the children() function:

$("#footer").children().fadeOut();


You may want to look into the 2nd parameter of the jQuery selector - "Selector Context", which is a great shorthand for searching for elements within a context.

The following would add a class of 'bar' to the span contained within a clicked div:

$('div.foo').click(function() {
  $('span', this).addClass('bar');
});

(from api documentation)

Internally, selector context is implemented with the .find() method, so $('span', this) is equivalent to $(this).find('span').

Further Reading..

  • jQuery API Doc on "Selector Context"
  • Previous Stack Overflow Question about jQuery & Chilren
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜