Uncaught TypeError: Cannot set property of undefined (set 'innerHTML')
P粉022140576
P粉022140576 2023-11-08 21:06:09
0
1
626

I'm trying to create a webpage using php, on an element of class "Continuous TextBox" (defined by my class), when clicked it has to start a Javascript function which should change the content id of another function" harta-modal" element, but this doesn't happen. I keep getting the same error, "Uncaught TypeError: Cannot set property of undefined (set 'innerHTML')" even though the function is declared after the element it is supposed to change, and the control I wrote within it Taiwan Log This function does not return null. What did i do wrong?

location.href='loginPage.html'"; } ?>    Crisis Containment Service    

Crisis Containment Service Web App

name, 0, 5) == date("m-d")){ ?>

description;?>


P粉022140576
P粉022140576

reply all (1)
P粉221046425

When usinggetElementByIdto get an element, you do not have to use[0]to access the first element since it can only return one element.

Frommozilla documentation:

So just use:

function makeMap(longitude, latitude){ console.log(document.getElementById('harta-modal')); document.getElementById('harta-modal').innerHTML = `${longitude} ${latitude}`; }
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!