M
M
Mixa19872018-02-21 16:47:52
JavaScript
Mixa1987, 2018-02-21 16:47:52

Can't reach span tag?

Tell me what I'm doing wrong?

<h1>До распродажы осталось <strong id="my_span_tag"></strong></h1>
  
<SCRIPT language=JavaScript>
    var months = ["январь","февраля","март","апрель","май","июнь","июль","август","сентябрь","октябрь","ноябрь","декабрь"];   

    function echo_date( date ) {
            echo_date = function(date){
                date = new Date( date );
                return {
                    "date" : date,
                    "month" : months[ date.getMonth() ],
                    "day_num" : date.getDate()
                };
            }
            return echo_date(date);  
        }; 
    var primer = echo_date( Date.now()+24*60*60*1000 );
    var result = primer.day_num+" "+primer.month;
    document.getElementById('my_span_tag').innerHTML = result.getFullYear();
</SCRIPT>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Arthur, 2018-02-21
@cloudz

Your result variable contains the string primer.day_num+" "+primer.month;
result.getFullYear() throws an error because it cannot get the year from the string "February 22"

M
Mixa1987, 2018-02-21
@Mixa1987

I still get the error Failed to load resource: net::ERR_FILE_NOT_FOUND

A
Ainur Valiev, 2018-02-22
@vaajnur

result must be a date object

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question