3
Hello
I’m developing a very simple javascript script, where when you first click on the button, it calls the function pupil() and by clicking the second time on same button calls the function teacher(), but nay I’m getting through alter the content of onclick, where I may be missing ?
<html>
<head>
<title>Mudar Botão</title>
</head>
<body>
<input type="button" id="btnAlunos" value="Alunos" onclick="alunos()" />
<script type="text/javascript">
function aluno() {
alert("Eu sou um aluno");
}
function professor() {
alert("Agora eu sou professor");
}
document.getElementById("btnAlunos").onclick = function() {
var btnAlunos = document.getElementById("btnAlunos");
btnAlunos.value = "Professor";
btnAlunos.onclick = "professor()";
btnAlunos.id = "btnProfessor";
aluno();
};
document.getElementById("btnProfessor").onclick = function() {
professor();
};
</script>
</body>
</html>
Thank you in advance
does the following, does the 2 functions attached to a different id when vc clika in the first after executing the function q vc either changes the id of the clikado item to the id that corresponds to the action of the second function.
– Jasar Orion