隐藏div并在悬停时显示其他DIV

时间:2013-03-27 14:11:53

标签: javascript css hover

如何在悬停时更改div?

这是我想要做的一个例子:JS FIDDLE

3 个答案:

答案 0 :(得分:1)

你真的想要JS吗?

<style>
    #container #divB{ display: none; }
    #container:hover #divB{ display: block; }
    #container:hover #divA{ display: none; }
</style>

<div id="container">
    <div id="divA">
        DIV A is visible until hover
    </div>
    <div id="divB">
        DIV B must show up after hover DIV A and DIV A must hide
    </div>
</div>

工作小提琴http://jsfiddle.net/KtckK/

答案 1 :(得分:0)

我更新了你的小提琴,这个例子使用了jQuery。

$('#divA').hover(

function () { // On mouse over
    $(this).hide(); // this references the div.
}

//function () { // On mouse out
//   $(this).show(); // this references the div.
//}
);

http://jsfiddle.net/eJ6Rq/11/

如果您正在寻找或不寻找,请告诉我。

答案 2 :(得分:0)

您可以尝试jQuery,请参阅http://jsfiddle.net/eJ6Rq/3/

$('#divA').hover(function(){$(this).hide(); $('#divB').show();});
相关问题