Ho trovato questo su un sito inglese:
Codice PHP:
<style>
.first{
background:silver;
padding:20px;
color:#ffffff;
}
.second{
background:yellow;
padding:30px;
color:#000000;
}
</style>
<script>
function changeClass(x)
{
x.className=(x.className=="first")?"second":(x.className=="second")?"first":"second";
}
</script>
<div id="my-div" class="first" style="width: 200px;" onclick="changeClass(this);">
Hi i am the text just when the page loads with a default class
</div>
Come faccio a far si che cambi la classe ad un altro elemento?