0

Pla help. JS - Can place a table element into a var by "getElelementById"? and if so what is the code to reach into an external

and if so what is the code to reach into an external html?

9th Mar 2020, 8:30 AM
jacob lipsky
jacob lipsky - avatar
7 Respostas
+ 1
Can you please explain your question better? If what you want is to put a table into a variable, you can simply assign it to getElementById, every element can be assigned to a variable.
9th Mar 2020, 8:52 AM
coddy
coddy - avatar
+ 1
If you want to change what is in a specific cell, you can use: var cell35 = document.getElementById("board").rows[5].cells[3]; Then, if you want to put an image in the cell: var cell = document.getElementById("board").rows[5].cells[3]; var img = document.createElement("img"); img.src = "image.png"; cell.appendChild(img); Note that 3 and 5 are example numbers, that are 5 on the y and 3 on the x. If all of this is a little vomplicated for you then I suggest you use a tutorial on a basic checkers game.
9th Mar 2020, 9:09 AM
coddy
coddy - avatar
0
I made a checker board using a table and uni code. I want now to start programing the javascript in an external ".js" page while using the DOME. -The table has an id "board". And i started off by coding : var t = document.getElementById("board").innerHTML; but gives me an error. How can i code it?
9th Mar 2020, 8:57 AM
jacob lipsky
jacob lipsky - avatar
0
The error that it gives me is: 'document' is not defined.[no-undef]
9th Mar 2020, 9:14 AM
jacob lipsky
jacob lipsky - avatar
9th Mar 2020, 9:59 AM
jacob lipsky
jacob lipsky - avatar
0
This is the code
9th Mar 2020, 9:59 AM
jacob lipsky
jacob lipsky - avatar
0
As you can see i just started learning...😬
9th Mar 2020, 10:00 AM
jacob lipsky
jacob lipsky - avatar