Exécution fonction sur onclick
Bonjour,
je ne comprends pas pourquoi le programme suivant ne fonctionne pas:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| <!DOCTYPE HTML>
<html>
<head>
<script language="javascript">
function ecritmessage() {
document.getElementById('mondiv').write('ceci est mon message');
}
</script>
</head>
<body>
<br>
<br>
<div id="mondiv" style="width:100px;height:100px;background-color:yellow;" onClick="ecritmessage()">
</div>
</body>
</html> |
alors que si supprime le getElementByid, ça fonctionne très bien.