I currently have the following script located in my .cshtml file:
<script type="text/javascript">
var d = new Date();
var month = d.getMonth;
window.onload = function () {
document.getElementById("currentMonth").innerHTML = month;
}
</script>
Now, I would like to access currentMonth inside of my span here:
<span style="font-size: 250%; color:red;">CURRENTMONTH HERE</span>
How do I do I access my javascript variable in plain text inside <span>
or am I going about this the wrong way?
What I am trying to accomplish is to display the current month in string format inside of the span. I have tried using @HttpContext.Current.Timestamp.Month
as well and this prints a 2 to the screen but the ToString()
for it does not work. I have never used Javascript before so please go easy.