I have 16 parts that make up whole picture shuffled on doc ready and now I must validate with an alert when whole picture is discovered. Also parts of picture shouldn't be available to switch again. I have tried this code:
fiddle: http://jsfiddle.net/w53Ls/4/
$(function() {
$("#puzzle").sortable({
update: function() {
var CorrectAnswers = ["bucata0", "bucata1", "bucata2", "bucata3", "bucata4", "bucata5", "bucata6", "bucata7", "bucata8", "bucata9", "bucata10", "bucata11", "bucata12", "bucata13", "bucata14", "bucata15"];
var UserAnswers = [];
$('#puzzle img').each(function(){
var imageId = $(this).attr("id");
UserAnswers += imageId.replace("recordArr_", "")+",";
});
UserAnswers = UserAnswers.substr(0,(UserAnswers.length) -1);
if(UserAnswers == CorrectAnswers){
alert("You Won");
}
}
});
});