This a sample code to show how i am using HTML tags inside of the javascript. I want to add CSS style to the table also, but its not working inside of the javascript code. Could anyone please suggest how to add CSS style to my html table inside of the javascript.
<html>
<body>
<style type="text/css">
table.imagetable
{
font-family: verdana,arial,sans-serif;
font-size:11px;
color:#333333;
border-width: 1px;
border-color: #999999;
border-collapse: collapse;
}
table.imagetable th
{
background:#b5cfd2 url('cell-blue.jpg');
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #999999;
}
table.imagetable td
{
background:#dcddc0 url('cell-grey.jpg');
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #999999;
}
</style>
<script language="JavaScript" >
function getSubmit()
{
var strHtml ="";
strHtml += "<table class = 'imagetable' >";
strHtml += "<tr>";
strHtml += "<th>S No</th>";
strHtml += "<th>Roll Number</th>";
strHtml += "<th>Name</th>";
strHtml += "<th>Maths</th>";
strHtml += "<th>Physics</th>";
strHtml += "<th>Chemistry</th>";
strHtml += "<th>Total</th>";
strHtml += "<th>Percentage</th>";
strHtml += "<th>Division</th>"
strHtml += "</tr>"
strHtml += "</table>";
document.write(strHtml);
}
</script>
<div align="center" style="border-bottom-color:#330000">
<table border="1" bordercolor="#000000" class= "imagetable">
<th>S No</th>
<tr align="center">
<td><input name="button" type="button" onClick="getSubmit()" value="submit"/></td>
</tr>
</table>
</div>
</body>
</html>
<head>
) refers totable.imagetable
but your code is writing a table with a class ofgridtable
– Mike W Jan 2 at 22:07