Hallo Community,
der folgende Code bewirkt nur das sich das div-Element bei Mausaktivität vergrößert, bzw. verkleinert. Macht es auch, allerdings nur im Firefox(2), im IE allerdings nicht (Opera hab ich nicht getestet).
PS: Hab gerade erst mit Javascript angefangen :).
var aktiv;
var i = 1;
var MinHoehe = 5;
var MaxHoehe = 100;
var Hoehe = parseInt(document.getElementById('button').style.height);
function Raus(){
if(Hoehe != 100){
window.clearInterval(aktiv);
aktiv = window.setInterval("Groesser()",10);
}
}
function Groesser(){
document.getElementById("button").style.height = Hoehe + i + "px";
Hoehe = parseInt(document.getElementById('button').style.height);
if(Hoehe == MaxHoehe){
window.clearInterval(aktiv);
}
}
function Rein(){
window.clearInterval(aktiv);
aktiv = window.setInterval("Kleiner()", 1);
}
function Kleiner(){
document.getElementById('button').style.height = Hoehe - i + "px";
Hoehe = parseInt(document.getElementById('button').style.height);
if(Hoehe <= MinHoehe) {
window.clearInterval(aktiv);
document.getElementById('button').style.height = "5px";
}
}
<body>
<div id="button" onmouseover="Raus()" onmouseout="Rein()" style="width:50px; height:5px; background-color:#FF0000;"></div>
</body>