简体   繁体   中英

Changing a value in Javascript doesn't seem to work

I've been trying to do a larger project and been coding in small chunks, but I came across trouble with what seems to be something very simple and I'd appreciate a few more eyes looking at this.

I'm trying to change a value of a button in a table. But I can't seem to get it to work. My html aside from the basic headings is . . .

<table id = "puzzle">
    <tr>
        <td> <button type = "button" id="b00"> 1 </button></td>
    </tr>
</table>

and my js is

document.getElementById("b00").innerHTML = "5";

Other things I've been doing have been working like printing and such. It should be noted that when I try to set the element equal to a var and print it, it prints null. Is that normal? Thanks for any help.

I had put the js file in the header and had made the html table in the body of the code. It couldn't find the table because it didn't exist yet. Full Credit to Diego Cardoso and James for helping me out.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM