Итак, я хочу иметь возможность загружать этот скрипт в виде отдельного файла и изменять стиль определенных тегов и вложенных тегов, основываясь на разных значениях.Например, если элемент таблицы <td>
имеет внутренний html «синий», он изменится на синий при загрузке тела;но мне нужно будет получить подэлементы, их подэлементы и т. д. Вот код:
function getTags() {
// Get all of the tags inside of the body
var mainnodes = document.body.childNodes;
// Get the number of nodes in the body
var mainlength = mainnodes.length;
// Assign the variable for the subnodes an their nodes and so on later
var subnodes, thirdnodes, fourthnodes, fifthnodes = ["Taco cat"];
// Create the for loop to iterate until all of the body elements have been passed throuh
for (i = 0; i < mainlength; i++) {
// Get the current node being passed through
var current = mainnodes[i];
// Get the number of subnodes
var sublength = current.childNodes.length;
// See if the body element does not have any subnodes
if (sublength === 0) {
continue;
} else {
for (c = 0; c < sublength; c++) {
subElements(current.childNodes[c]);
}
} // End of the: no body element sub element if statement
} // End of the body element for loop
} // End of the get tags functions
function subElements(toiterate) {
var giveback = ["Hello World"];
for (a = 0; a < toiterate.length; a++) {
var current = toiterate[i];
var subs = current.childNodes;
if (subs.length === 0) {
continue;
} else {
for (b = 0; b < subs.length; b++) {
if (b === 0) {
giveback = subs[b];
} else {
giveback += subs[b];
if (b == subs.length) {
}
}
}
}
}
}