I try to write these code to make grid view through CSS:( jsbin )
var tables = document.getElementsByClassName(\'tableData\'); var rows = tables[0].getEle
This should work even when the attribute isn't already present:
rows[i].setAttribute("class", "alt");
http://www.w3schools.com/Dom/met_element_setattribute.asp