Tyler Dunn
Tyler Dunn

Reputation: 85

Load Element from Specific Div JS

What I need to do is load only the second table (Or tbody) element (Un-named and has no class), from the div named megaContent. What I'm planning to do is have the browser go to the page, then load this JS and have it display that part only.

Upvotes: 0

Views: 57

Answers (1)

Sam Braslavskiy
Sam Braslavskiy

Reputation: 1288

it is not perfectly clear what do you mean by "LOAD only the table". if you'd like to DISPLAY only the table and you don't know how to reach it since it does not have any class or id, you could do something like this:

var tbls = document.getElementById("megaContent").getElementsByTagName("table");
var tbl = tbls[0]; // [0] if the desired table is the first table in that div, [1] if second etc.
tbl.style.display="block"; //or "table", or whatever you'd like to do with that table.

hope this helps.

Upvotes: 1

Related Questions