如何使用addClass和removeClass jquery

时间:2014-07-03 05:13:04

标签: jquery css

我希望.car-info dorpdown当.title-bar是鼠标悬停所以.car-info addClass .........

$(".items .title-bar").on("mouseover", function () {
   //i wanted .title-bar is addClass down
   // .carinfo on mouseover is addClass down
});
$(".items .title-bar").on("mouseout", function () {
   //i wanted .title-bar is removeClass down
  // carinfo on mouseover is removeClass down
 });

我想要这种风格

enter image description here

当我悬停时

enter image description here

请参阅http://jsfiddle.net/kisspa/n9rLF/3/

1 个答案:

答案 0 :(得分:1)

试试这个

$(".items").on("mouseover", function () {
    $(this).find('.title-bar').addClass('down')
    $(this).find('.car-info').addClass('down')

});
$(".items").on("mouseout", function () {
    $(this).find('.title-bar').removeClass('down')
    $(this).find('.car-info').removeClass('down')

});

DEMO