1
I have a calendar where every day is:
<a class="dia" href="#">(Número do dia, ex: 1, 2, 3, etc)</a>
Then I need that whenever the class "day" is clicked it calls a function, for example the test function().
I did this below, but the problem is that I can only choose 1 class, I want it to work with any one:
<a class="dia" href="#">1</a>
<a class="dia" href="#">2</a>
<script>
document.getElementsByClassName("dia")[0].onclick = function() {teste()};
function teste() {
alert("Deu Certo!");
}
</script>
It worked, but not completely on the calendar I’m using, for some reason on the calendar it only works the first click, then it doesn’t work anymore.
– Leandro Teraoka
I incremented the answer see if it works.
– RFL