0

我有 3 个盒子:kotak1、kotak2 和 kotak3。

#kotak1有测试"COBA AKU"

CSS:

<style>
    body {
        margin: 0;
        padding: 0;
    }
    #mainCont {
        margin: 0 auto;
        width: 1024px;
        height: 768px;
        background-color: #F00;
    }
    #kotak1{
        width: 1024px;
        height: 768px;
        background-color: #0F9;
        text-align: center;
        vertical-align: middle;
    }
    #kotak2{
        width: 240px;
        height: 768px;
        background-color: #666;
        float: left;
    }
    #kotak3{
        width: 240px;
        height: 768px;
        background-color: #03F;
        float: right;
    }
</style>

HTML:

<body>
    <div id="mainCont">
        <div id="kotak2"></div>
        <div id="kotak3" onmouseout="keluarkotak()"></div>
        <div id="kotak1">
            COBA AKU
        </div>
    </div>
</body>

我想将文本更改#kotak1"SELESAI TIDUR"当您将鼠标移出#kotak3并输入时#kotak2

4

1 回答 1

0

这是一个小提琴:http: //jsfiddle.net/PZfwT/1

这是支持代码,只需管理您是否离开了三个,然后当您的鼠标输入 2 时,您可以更改 1 的文本。我建议使用 jQuery 进行此操作,如果这样做,整体管理会更容易。

(function() {
    var mousedOutThree = false;

    window.App = {
        kotak2In: function() {
            if (mousedOutThree) {
                mousedOutThree = false;
                document.getElementById("kotak1").innerHTML = "SELESAI TIDUR";   
            }
        },

        kotak3Out: function() {
            mousedOutThree = true;
        }
    };
})();
于 2013-05-07T18:12:03.547 回答