java脚本函数在2个mouseevent条件后运行
问题描述:
我有3个框:kotak1,kotak2和kotak3。java脚本函数在2个mouseevent条件后运行
#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
。
答
这里有一个小提琴: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;
}
};
})();
+0
非常感谢你,它真的帮助我 – user2359398 2013-05-08 00:40:10
显示您尝试过的内容,我们将帮助您解决问题。如果它无法正常工作,请确保您检查了Javascript控制台的错误。 – Barmar 2013-05-07 18:01:58
我同意。这里需要有一些JavaScript函数来查看错误的位置。即使它不工作,发布你的尝试也是有帮助的,这样你可以知道你的代码出错了,或者你可能会遇到问题的解决方法。 – RacerNerd 2013-05-07 18:18:26