<input type="button" onclick="move()" value="go" />
<br />
<img src="btn16.gif" style="height:100px; width:100px; top:0px" id="img" />
<script>
var k=0;
function move(){
var t=document.getElementById("img").style.top;
t=parseInt(t);
t+=15;
document.getElementById("img").style.top=t;
if(k<10){
k++;
setTimeout("move()",1);
}
}
</script>
kracko
0
Light Poster
Recommended Answers
Jump to PostTha basic problem is that for the image to be movable the style
position:relative;
must be present.This little toy
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta name="generator" content= "HTML Tidy for Windows (vers 25 March 2009), see www.w3.org"> <title></title> </head> <body> …
Jump to Postdocument.getElementById("img").style.top=t;
The problem is the code line above. For firefix, it must be...
document.getElementById("img").style.top=t+"px";
All 5 Replies
kracko
0
Light Poster
fxm
23
Posting Pro
kracko
0
Light Poster
Taywin
312
Posting Virtuoso
kracko
0
Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.