Javascript won't apply css-style on dynamic table -
Javascript won't apply css-style on dynamic table -
after research on net discovered can add together css-class new created row .classname:
<tr id="producttablerow" onclick=' var table = document.getelementbyid("cardtable"); var row = table.insertrow(-1); var cell1 = row.insertcell(0); cell1.classname ="cardlefttd"; var cell2 = row.insertcell(1); cell2.classname ="cardcentretd"; var cell3 = row.insertcell(2); cell3.classname ="cardrighttd"; cell1.innerhtml = "new cell1"; cell2.innerhtml = "new cell2"; cell3.innerhtml = "new cell3"; '>
but when run on website, can see there no style applied, there's style applied on static part of website, css working fine, guess problem in javascript part above, , uncertainty if sentence right:
cell3.classname ="cardrighttd";
the onclick working fine, i've tried alert. thanks!
from comments above, explain why dot fixed it.
in css, # used reference id. a class referenced dotthe javascript adding classes , not ids.
if used on more 1 element on page, should utilize class , not id. id's should used refer single item if want code validate.
javascript css
Comments
Post a Comment