I have been looking at the following code for a few minutes and the problem is escaping me. How can I make each of these events that produce alerts work?
<html>
<head></head>
<body>
[ <span id="trad_alert">traditional alert</span> ]
[ <span onclick="inlineAlert ();">inline alert</span> ]
<script type="txt/javascript">
document.getElementById("trad_alert").onclick = function () {
alert ("traditional alert");
}
function inlineAlert () {
alert ("inline alert");
}
</script>
</body></html>
Searching Stack Overflow or the web produce numerous examples that appear identical to what I'm trying, but yet mine continues to fail.
Your script type is wrong.
Either change it to <script type="text/javascript"> or remove the type altogether.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With