Topic verplaats naar OOP omdat je het topic niet kan zien in webdesign


Beste php'ers,

Ik heb een stukje code die een div leeg maakt als ik ergens op klik,
Hier moet weer een plaatje in komen te staan als hij opnieuw start, maar dat doet hij niet.

Weet iemand wat hier niet aan klopt?

$(function() {
    var left = 0;
    var step = 50;
    var count = 1;
    var max = 8;
    
    
    var left2 = 500;
    var step2 = 75;
    var count2 = 1;
    var max2 = 7;
    
    var width = 500;
    var height = 150;
    var arr = new Array(50,33,25,33,25,33,50,25);
    for (num=0;num<arr.length;num++) {
	    
	    $("#float").animate({height: arr[num]+'px',"left": "0px","top": "0px"},0);
	    $("#float2").animate({height: arr[num]+'px',"left": "500px","top": "500px"},0);
	    
	    $('#float').html('<img style="width:100%; height:100%;"; src="images/schietschijf.png" alt="" onclick="hit(1,\'float\');"/>');
	    $('#float2').html('<img style="width:100%; height:100%;"; src="images/schietschijf.png" alt="" onclick="hit(1,\'float2\');"/>');
	    
	    $("#float").animate({width: arr[num]+'px'},300);
	    $("#float2").animate({width: arr[num]+'px'},300);  
	     
	    for(i=0; i<width/step;i++) {
		    
	        $("#float").animate({
	            "left": left+"px",
	            "top": (Math.random()*height)+"px"
	        }, 500);
	        left = left + step;
	        count++;
	        
	        if(count2 <= max2) {
		        
		        $("#float2").animate({
		            "left": left2+"px",
		            "top": (Math.random()*height)+"px"
		        }, 500);
		        left2 = left2 - step2;
		        count2++;
	        }
	        
	    }
	    left = 0;
	    left2 = 500;
	    
	    count = 1;
	    count2 = 1;
	    
	    $("#float").animate({width: '0px', height: '0px'},0);  
	    $("#float2").animate({width: '0px', height: '0px'},0); 
    }                          
});
var score2 = 0;

function hit(addscore,div) {

	$('#score').html((score2 + addscore) + ' punten');
	$('#'+div).html('');
	score2++;
}


<html>
<head>
    <script type="text/javascript" src="js/jquery/jquery.js"></script>
    <script type="text/javascript" src="js/schiettraining.js"></script>
    <style type="text/css">
        #float {
	        	width: 0px;
            position: absolute;
            background-color:#FF0000;
        }
        #float2 {
	        	width: 0px;
            position: absolute;
            background-color:#FF0000;
        }
    </style>    
</head>
<body>
<div id="float"><img style="width:100%; height:100%;"; src="images/schietschijf.png" alt="" onclick="hit(1,'float');"/></div>
<div id="float2"><img style="width:100%; height:100%;"; src="images/schietschijf.png" alt="" onclick="hit(1,'float2');"/></div>
<div id="score"></div>
</body>
</html>

Tom schreef op 06.02.2010 13:10


Haal die $("#float").html(''); en $("#float2").html(''); is weg:P


Dat is eigenlijk niet de bedoeling, als je erop hebt geklikt moet hij weg gaan en als die weer opnieuw start moet hij terugkomen.

Reageren