How to use   inside of div > script

yotube
0

Issue

I want to use &nbsp inside of my script :

              <div class="badge-danger" id="current_date">
<script>
function CurrentDate() {
let current = new Date();
let cDate = current.getDate() + ' - ' + (current.getMonth() + 1) + ' - ' + current.getFullYear();
let cTime = current.getHours() + ":" + current.getMinutes() + ":" + current.getSeconds();
let dateTime = cDate + ' ' + cTime;
document.getElementById("current_date").innerHTML = dateTime;
}
setInterval(CurrentDate, 1000);
</script>
</div>

I don't know where to do it inside of this div I'm used to do it like this :

                <span style="font-weight: bold">&nbsp;Flash&nbsp;News</span>

Any Idea ?


Solution

You can use the html code in your string as it goes to innerHTML anyway. So for example let dateTime = cDate + '&nbsp;' + cTime; works



Answered By - IT goldman

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !
To Top