This is my code.
var blank_left = 180;
var blank_top = 180;
var cardset = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15];
cardset.sort(function(){ return 0.5 - Math.random()});
$('#wrapper div').each(function(){
$(this).css('left',$(this).attr('id')%4*60)
.css('top',Math.floor($(this).attr('id')/4)*60)
.html(cardset[$(this).attr('id')])
});
$('#wrapper div').click(function(){
if(Math.abs(parseInt($(this).css('left'))-blank_left)+Math.abs(parseInt($(this).css('top'))-blank_top)==60){
var old_left = blank_left;
var old_top = blank_top;
blank_left = parseInt($(this).css('left'));
blank_top = parseInt($(this).css('top'));
$(this).animate({left: old_left, top: old_top}, 150);
}
});
What it does is that it takes the array in cardset and makes them random then printing them to my divs in an random order. What I wanna do is when i move my divs I want the script to check if I have moved the divs in the right order. The right order being my cardset array. So it should check with the array cardset if all numbers are in the right order.
For example: if cardset = true then alert('Done!');
Hope you understand.