Les comparto mi código JavaScript (no tiene todo lo del taller porque estoy usando pug para generar el contenido HTML)
(
() => {
let juego = true;
function jugar(elementoSeleccionado) {
let p = document.createElement('p');
p.style.fontWeight ='bold';
p.style.top = '42%';
p.style.right = '47%';
p.style.display = 'inline';
p.style.position = 'absolute';
p.innerHTML = juego ? 'X' : 'O';
elementoSeleccionado.appendChild(p);
}
let elements = document.querySelectorAll('.cat-element');
elements.forEach(element => {
element.addEventListener('click',function() {
if(!this.hasChildNodes()) jugar(this);
});
});
}
)();
(
() => {
let juego = true;
function jugar(elementoSeleccionado) {
let p = document.createElement('p');
p.style.fontWeight ='bold';
p.style.top = '42%';
p.style.right = '47%';
p.style.display = 'inline';
p.style.position = 'absolute';
p.innerHTML = juego ? 'X' : 'O';
elementoSeleccionado.appendChild(p);
}
let elements = document.querySelectorAll('.cat-element');
elements.forEach(element => {
element.addEventListener('click',function() {
if(!this.hasChildNodes()) jugar(this);
});
});
}
)();