Javascipt Trying to get contents of tage
تبليغيرجى شرح بإيجاز لمإذا تشعر أنك ينبغي الإبلاغ عن هذا السؤال.
I have been trying to get full detail of a series of tags on an HTML page
I can get the ID and text but all other values elude me
The HTML looks like this
1.1.1.1 Caja
The code that works
var myarray = []
for (var i=0; i<x.length; i++){
var allcontent = x[i].elements
var nametext = x[i].textContent;
var cleantext = nametext.replace(/s+/g, ‘ ‘).trim();
var classtype = x[i].class;
var nombretxt = x[i].nombre;
var idno = x[i].id;
var padreno = x[i].padre;
myarray.push([idno,nametext]);
};
function make_table() {
var table = ‘<table><thead><th>idno</th><th>nametext</th></thead><tbody>’;
for (var i=0; i<myarray.length; i++) {
table += ‘<tr><td>’+ myarray[i][0] + ‘</td><td>’+myarray[i][1]+'</td></tr>’;
};
var w = window.open(“”);
w.document.write(table);
}
make_table()
I need to get the values of class= codigo= padre= nombre= into the array as well
but experimenting with var nombretxt = x[i].nombre; and similar does not return a value
Many thanks
أضف إجابة