Recentemente, escrevi outro projeto e usei o InnerHTML, mas depois que eu descobriu que, depois de chamar o Innerhtml, o OnClick foi invalidado. diretamente, mas pode ser implementado indiretamente.
Exemplo 1: este exemplo é ondlick que não pode ser alcançado
Copie o código do código da seguinte forma:
<html>
<head>
<script adie>
Função inscell (th)
var name = th.name;
var id = th.id;
if (nome == "não") {{
id.innerhtml = "<tipo de entrada = 'botão' onclick = 'inscall (this)' value = 'online'
nome = 'não' id = '1'> "";
} Outro {
id.innerhtml = "<tipo de entrada = 'botão' onclick = 'inscall (this)' value = 'offline'
nome = 'sim' id = '1'> "" ";
}
</script>
</head>
<Body>
<br />
<span id = "msg">
<input type = "button" onclick = "inscall (this)" value = "offline" name = "sim" id = "1">
</span>
</body>
</html>
O exemplo acima é julgar se está online com base no nome do botão ou offline ~~~ descobrimos que quando você clicar na primeira vez, você será inválido ~~~~~~~~
Neste momento, podemos perceber disfarce, como segue:
Copie o código do código da seguinte forma:
<html>
<head>
<script adie>
Função inscell (th)
{{
Var nome = th.name;
var id = th.id;
alerta (nome+"-"+id);
var span = document.getElementById (id);
if (nome == "não") {{
span.innerhtml = "<tipo de entrada = 'botão' 'value =' offline '>";
span.name = "sim";
} Outro {
span.innerhtml = "<tipo de entrada = 'botão' 'value =' go online '>";
span.name = "não";
}
}
</script>
</head>
<Body>
<br />
<span id = "1" onclick = "inscell (this)" name = "no">>
<input type = "button" value = "online">
</span>
</body>
</html>