signore del tempo
Utente Èlite
- Messaggi
- 3,228
- Reazioni
- 491
- Punteggio
- 70
Quindi dov'è che hai problemi?
Segui il video qui sotto per vedere come installare il nostro sito come web app sulla tua schermata principale.
Nota: Questa funzionalità potrebbe non essere disponibile in alcuni browser.
Pubblicità
function crea_scacchiera(){
document.write('<div id=tavola>');
var colore = "";
var num = 0;
for(i=0;i<8;i++)
{
for(j=0;j<8;j++)
{
((i+j)%2 !=0) ? colore='bianco' : colore='nero';
document.write('<div class='colore' id='num'>');
num++;
}
}
document.write('</div>');
}
<div id=tavola>
function crea_scacchiera(){
var tavola = document.createElement("div");
var nuova_cella = document.createElement("div")
var colore = "";
var num = 0;
for(i=0;i<8;i++)
{
for(j=0;j<8;j++)
{
tavola.appendChild(nuova_cella)
((i+j)%2 !=0) ? colore='bianco' : colore='nero';
setAttribute(????)
num++;
}
}
}
#tavola {
weight: 800px;
height: 800px;
}
*.bianco
{
margin: 0px;
padding: 0px;
weight: 100px;
heignt: 100px;
backgroung-color: white;
z-index: 0;
}
*.nero
{
margin: 0px;
padding: 0px;
weight: 100px;
heignt: 100px;
backgroung-color: black
z-index: 0;
}
<html><head>
<script type="text/javascript" src="scacchiera.js"> </script>
<title>Scacchiera</title>
</head>
<body style="background-color: gray;">
</body>
</html>
function image(){
var img1, img2, br;
br=document.createElement("br");
img1= new Image();
img2= new Image();
img1.src="http://i46.tinypic.com/2z8421s.png";
img2.src="http://i48.tinypic.com/2zjjcye.png";
for (i=0; i<3; i++)
{
img1= new Image();
img2= new Image();
img1.src="http://i46.tinypic.com/2z8421s.png";
img2.src="http://i48.tinypic.com/2zjjcye.png";
document.body.appendChild(img1);
document.body.appendChild(img2);
}
document.body.appendChild(br);
for (i=0; i<3; i++)
{
img1= new Image();
img2= new Image();
img1.src="http://i46.tinypic.com/2z8421s.png";
img2.src="http://i48.tinypic.com/2zjjcye.png";
document.body.appendChild(img2);
document.body.appendChild(img1);
}
br=document.createElement("br");
document.body.appendChild(br);
for (i=0; i<3; i++)
{
img1= new Image();
img2= new Image();
img1.src="http://i46.tinypic.com/2z8421s.png";
img2.src="http://i48.tinypic.com/2zjjcye.png";
document.body.appendChild(img1);
document.body.appendChild(img2);
}
br=document.createElement("br");
document.body.appendChild(br);
for (i=0; i<3; i++)
{
img1= new Image();
img2= new Image();
img1.src="http://i46.tinypic.com/2z8421s.png";
img2.src="http://i48.tinypic.com/2zjjcye.png";
document.body.appendChild(img2);
document.body.appendChild(img1);
}
br=document.createElement("br");
document.body.appendChild(br);
}
document.addEventListener("DOMContentLoaded",image, false );
window.onload=function()
{
var img = document.getElementsByTagName("img");
for (i = 0; i<img.length; i++)
{
img[i].onclick = function()
{
if (this.src == "http://i46.tinypic.com/2z8421s.png")
{
this.src="http://i49.tinypic.com/vuts7.png";
}
else if (this.src == "http://i48.tinypic.com/2zjjcye.png")
{this.src = "http://i46.tinypic.com/33z2r90.png";
}
}
}
}
<HTML><HEAD>
<style type="text/css">
#dama {
border: 1px solid maroon;
border-collapse:collapse;
}
#dama td.scuro {
padding:0px;
width:80px;
height:80px;
background-color: #deb887
}
#dama td.chiaro {
padding:0px;
width:80px;
height:80px;
background-color:#fdf5e6
}
</style>
</HEAD>
<BODY>
<script type="text/javascript">
var colore;
document.write('<table id = "dama">');
for (i=1; i<=8; i++) {
document.write('<tr>')
for (j=1; j<=8; j++) {
if ((i+j) % 2 !=0) {
document.write('<td class= "scuro">')
}
else {document.write('<td class= "chiaro">')}
document.write(' </td>');
}
document.write('</tr>');
}
document.write('</table>');
document.close();
</script>
</BODY>
</HTML>
Non ho capito...Sono andato ai colloqui ed il professore mi ha consigliato di usare una struttura in html iuttosto che una scacchiera di immagini, sostiene che per gestire poi gli eventi successivamente mi rimarrà più semplice![]()