
Nefunkční script v JS
Ahoj,
chtěl bych prosím poradit proč mi nefunguje tento script.
<span>První</span>
<span>Druhý</span>
<script>
document.getElementsByTagName("span").onclick = function(){
if (document.this.style.color == 'green' )
document.this.style.color = 'red';
else if (document.this.style.color == 'red' )
document.this.style.color = 'green';
else
document.this.style.color = 'black';
}
</script>
Můžete mi poradit? Děkuji
Zapni si chybovou konzoli a přečti si to.... Takhle se jinak nic nenaučíš.
Aha, tak se omlouvám. Nevěděl jsem že to umí jen ten jquery, mám pouze javascript.
Díky za radu.