Strona miała być grą polegającą na przesówaniu fragmentów podzielonego na małe części zdjęcia.
Poniżej cały kod strony.
Kod
<html lang='eng'>
<head>
<meta charset="UTF-8">
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title>Document</title>
<style>
div{
position:absolute;
width: 100px;
height: 100px;
border: red 2px solid;
}
img{
width: 100px;
height: 100px;
}
</style>
<script>
function generator(){
var num=4, newdiv, divIdName;
for (var i=0; i<num; i++)
for(var j=0; j<num; j++){
newdiv=document.createElement('div');
divIdName= 'a'+i+j;
newdiv.setAttribute('id', divIdName);
newdiv.style.top=100+'px';
newdiv.style.left=100+100*j+'px';
if(i*j=!9)
newdiv.innerHTML= "<img src='slice_"+i+"_"+j+".jpg'>";
newdiv.addEventListener('click', function(){Graj(this);});
document.body.appendChild(newdiv);
}
}
function Graj(x){
var bufor;
if(x.style.top==a33.style.top & x.style.left== 100+'px'){
bufor=x.style.left;
x.style.left=a33.style.left;
a33.style.left=bufor;
}
if (x.style.left==a33.style.left & x.style.top== 100+'px'){
bufor=x.style.top;
x.style.top=a33.style.top;
a33.style.top=bufor;
}
}
</script>
<!--parseInt!!!!
poprawić możliwość zmieny dalszych kafelków, dołożyć licznik, cały obrazek wyświetlic obok, dodać parę obrazków, -->
</head>
<body onload='generator()'>
<input type='button' value='Mieszaj' onclick='Mieszaj()'>
<!--Dodać to do memory - na lepszą ocenę-->
</body>
</html>
<head>
<meta charset="UTF-8">
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title>Document</title>
<style>
div{
position:absolute;
width: 100px;
height: 100px;
border: red 2px solid;
}
img{
width: 100px;
height: 100px;
}
</style>
<script>
function generator(){
var num=4, newdiv, divIdName;
for (var i=0; i<num; i++)
for(var j=0; j<num; j++){
newdiv=document.createElement('div');
divIdName= 'a'+i+j;
newdiv.setAttribute('id', divIdName);
newdiv.style.top=100+'px';
newdiv.style.left=100+100*j+'px';
if(i*j=!9)
newdiv.innerHTML= "<img src='slice_"+i+"_"+j+".jpg'>";
newdiv.addEventListener('click', function(){Graj(this);});
document.body.appendChild(newdiv);
}
}
function Graj(x){
var bufor;
if(x.style.top==a33.style.top & x.style.left== 100+'px'){
bufor=x.style.left;
x.style.left=a33.style.left;
a33.style.left=bufor;
}
if (x.style.left==a33.style.left & x.style.top== 100+'px'){
bufor=x.style.top;
x.style.top=a33.style.top;
a33.style.top=bufor;
}
}
</script>
<!--parseInt!!!!
poprawić możliwość zmieny dalszych kafelków, dołożyć licznik, cały obrazek wyświetlic obok, dodać parę obrazków, -->
</head>
<body onload='generator()'>
<input type='button' value='Mieszaj' onclick='Mieszaj()'>
<!--Dodać to do memory - na lepszą ocenę-->
</body>
</html>
Bardzo proszę o pomoc w znalezieniu błędu.