I have an AJAX function in my JavaScript like so
function getWeather(countryName) {
const monthNames = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
];
let dateObj = new Date();
let month = monthNames[dateObj.getUTCMonth()];
let day = dateObj.getUTCDate() - 1;
let year = dateObj.getUTCFullYear();
let newDate = `${month} ${day}, ${year}`;
$.ajax({
url: "assets/geojson/countryBorders.geo.json",
type: "GET",
dataType: "json",
data: {
},
success: function(result) {
.... etc
Within my HTML modal for displaying the weather per country, I would like to include things such as the date.
Is there any way to use the Javascript variable newDate
in the HTML script?
something like ....?
<div class="modal-body">
<h6 id="capitalCity" class="modal-sub-header"></h6>
<hr>
<ul class="dem">
<p class="date" id="newDate"></p>