How do I get a CSS class to show up in my javascript with my previous method? -


i having trouble getting work. class works caption (because there 1 caption tag throughout html). doesn't work tr tag because work have use loop. here code works caption, how work tr?

window.onload = function() {      var caption = document.getelementsbytagname("caption");     var oldcaption = caption[0].innerhtml;     var newcaption = "caption";      var span = document.createelement('span');     var text = document.createtextnode(newcaption);     span.appendchild(text);     span.classname = "hovernode";     caption[0].appendchild(span); } 

here's tr section:

var tr = document.getelementsbytagname("tr");  (i = 0; < tr.length; i++) {      var newtr = "tr";      tr[i].removechild(tr[i].firstchild);     tr[i].appendchild(document.createtextnode(newtr)); } 

do same way single caption. create span in loop, , give class want.

for (i = 0; < tr.length; i++) {      var newtr = "tr";     var span = document.createelement('span');     var text = document.createtextnode(newtr);     span.appendchild(text);     span.classname = "hovernode";      tr[i].removechild(tr[i].firstchild);     tr[i].appendchild(span); } 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

dataset - MPAndroidchart returning no chart Data available -

java - No use of nillable="0" in SOAP Webservice -