将CSS添加到使用javascript创建的表中 [英] Add CSS to the table created from javascript

查看:66
本文介绍了将CSS添加到使用javascript创建的表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  var  num;
    var  uniqueName =  Date();

    var  windowName = ' 打印' + uniqueName .getTime();
    var  printWindow = window.open(num,windowName,'  left = 50000,top = 50000,width = 0,height = 0');

   printWindow.document.write(" );
   printWindow.document.close();
   printWindow.focus();
   printWindow.print();
   printWindow.close(); 





在这种情况下如何将CSS类应用于创建的表
我想将CSS类应用于此表
怎么做.

#客户  tr . alt   td 
{
颜色 : #000000; 
背景色 : #EAF2D3; 
} 




请帮帮我.

在此先感谢

解决方案

您需要发出包含CSS或从外部文件加载CSS的HTML.

您的问题与C#无关.


  var  myTable = ' '  myClass'; 


var num;
   var uniqueName = new Date();

   var windowName = 'Print' + uniqueName.getTime();
   var printWindow = window.open(num, windowName, 'left=50000,top=50000,width=0,height=0');

   printWindow.document.write("<table id='customers'  border='1' cellpadding='0' cellspacing='0' style='width:80%; border-collapse:collapse;text-align:left'><tr><td><b>Date</b></td><td >8/8/2011</td></tr><tr><td><b>Project</b></td><td>Sample Project</td></tr></table>");
   printWindow.document.close();
   printWindow.focus();
   printWindow.print();
   printWindow.close();





how to apply css class in this case to the table that is created
i want to apply css class to this table
How to do this.

#customers tr.alt td
{
color:#000000;
background-color:#EAF2D3;
}




Please help me.

Thanks in advance

解决方案

You need to emit HTML that either includes the CSS, or loads the CSS from an external file.

Your question has nothing to do with C#.


var myTable = document.getElementById('myTable');
myTable.className = 'myClass';


这篇关于将CSS添加到使用javascript创建的表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆