Inline Javascript not executed
2 answers
onload is not what you want (it doesn't even work), you need to execute this on document.ready
I think you are mixing jQuery and JavaScript, try using document.ready
in a script block.
First we will give your ID range
<span id="yourSpan"></span>
Then we can do:
<script type="text/javascript">
$(function () {
$("#yourSpan").text(moment().format('MMMM Do YYYY, h:mm:ss a'));
});
</script>
EDIT: As you said, you want it inline (although this is really bad practice and I'll have to wash my hands after writing it), add your ID to your range as above, but do this:
<body onload="$('#yourSpan').text(moment().format('MMMM Do YYYY, h:mm:ss a'));">
+8
source to share