I have the following script, as seen, it calls the Date method onClick event, like so:
<!DOCTYPE html>
<html>
<body>
<p onclick='this.innerHTML = Date();'>click me!</p>
</body>
</html>
How can I do the same with an onLoad
event? I don’t want to define it with a separate <script>
tag and call it as a function
. I’d like the most minimal coding.
Why doesn’t the following work?
<!DOCTYPE html>
<html>
<body>
<p onload='this.innerHTML = Date();'>date here onload</p>
</body>
</html>