I want to reflect the return value of the date function that displays the date.

Asked 2 years ago, Updated 2 years ago, 17 views

I have a question about javascript,html.
I would like to reflect the return value of the date function that displays the date in the code below.

$("#board").prepend("<licclass='board'>"+data.value.message+"<button id='button'></button></li>");

date function (confirmed by console)

function date(){
    myTbl = new Array ("Sun", "Mon", "Tuesday", "Wednesday", "Thursday", "Friday", "Sat");
    myD = new Date();
    myYear=myD.getFullYear();
    myMonth=myD.getMonth()+1;
    myDate=myD.getDate();
    myDay=myD.getDay();
    myHours=myD.getHours();
    myMinutes=myD.getMinutes();
    mySeconds = myD.getSeconds();
    myMess1=myYear+"year"+myMonth+"month"+myDate+"day";
    myMess2 = myTbl [myDay] + "Day of Week";
    myMess3=myHours+"hour"+myMinutes+"minute"+mySeconds+"second";
    myMess=myMess1+"+myMess2+"+myMess3;
    return myMess;
}

date(); 
console.log(date());

javascript

2022-09-29 22:37

1 Answers

You can combine it with the + operator where you want to reflect it.
button If you want to include it in the element:

$("#board").prepend("<licclass='board'>"+data.value.message+"<button id='button'>"+date()+"</button></li>";


2022-09-29 22:37

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.