javascript bananacal

Claicaacron

New Member
I wrote a javascript Code for a project I have to do for school. My Idea was to display random bananas on the screen by clicking on a button. So I wrote this code .. but it doesn't work!\[code\]<script>function bananenapokalypse() {var t=10.20;var myVar=setInterval(function(){myTimer()},200);}function myTimer(){var zufall=Math.floor(Math.random() * 1100) + 1;var zufall2=Math.floor(Math.random() * 1000) + 1;var zufall3=Math.floor(Math.random() * 1250) + 1;var zufall4=Math.floor(Math.random() * 900) + 1;var grose =Math.floor(Math.random() * 200) + 1;var grose2 =Math.floor(Math.random() * 300) + 1;var grose3 =Math.floor(Math.random() * 200) + 1;document.getElementById("demo").innerHTML+= '<div class="bananenapokalypse" style="top: '+zufall+';right: '+ zufall2+ ';"><img src="http://stackoverflow.com/questions/15859881/bilder/banane.png" width="'+ grose +'"/></div>';document.getElementById("bananenapokalypse").innerHTML+='<div class="bananenapokalypse" style="top: '+zufall2+';right: '+ zufall3+ ';"><img src="http://stackoverflow.com/questions/15859881/bilder/banane.png" width="'+ grose2 +'"/></div>';document.getElementById("bananenapokalypse").innerHTML+= '<div class="bananenapokalypse" style="top: '+zufall3+';right: '+ zufall4+ ';"><img src="http://stackoverflow.com/questions/15859881/bilder/banane.png" width="'+ grose3 +'"/></div>';document.getElementById("bananenapokalypse").innerHTML+='<div class="bananenapokalypse" style="top: '+zufall4+';right: '+ zufall+ ';"><img src="http://stackoverflow.com/questions/15859881/bilder/banane.png" width="'+ grose +'"/></div>';}</script> </head><body id="bananenapokalypse"><p id="demo"><a href="javascript:bananenapokalypse()"><button><span class="energie">Energie?</span><br /><br />[Starte die Bananenapokalypse]</button></a></p>\[/code\]I also know that the code isn't neatly arranged... But it's for school and the topic was about HTML and not javascript.Do you know why it's not working?
 
Back
Top