如何为我的标题添加bg颜色 [英] how can add bg color to my header

查看:102
本文介绍了如何为我的标题添加bg颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
我正在使用javascript打印表格
如何为我的标题添加背景颜色
我的代码是

hi
i am using javascript to print a table
how can add background colour to my header
my code is

var r1 = document.createElement("tr");
var h2 = document.createElement("th");
                        var a2 = document.createElement("a");
                       // a2.setAttribute("href","JavaScript:none{0};");
                       // a2.setAttribute("onclick","SortByName()");
                        a2.appendChild(document.createTextNode("DeptID"));
                        h2.appendChild(a2);
                        r1.appendChild(h2);
                         tb.appendChild(r1);




谢谢
vara prasad




thank you
vara prasad

推荐答案

我不太了解您在做什么,但是您可以更改元素的样式,如下所示:

Object.style.backgroundColor ="color | inherit | transparent"

http://www.w3schools.com/jsref/prop_style_backgroundcolor.asp [
I do not really understand what you are doing, but you can change the style of an element like this:

Object.style.backgroundColor="color|inherit|transparent"

http://www.w3schools.com/jsref/prop_style_backgroundcolor.asp[^]


http://www.java2s.com/cn/code/javascript/table/tablecellbackgroundcolorexample.htm /www.java2s.com/Code/JavaScript/Table/TableCellbackgroundColorExample.htm"target =" _ blank"title =" New Window> ^ ]

http://blogs.sitepoint.com/background-colors-javascript/ [
http://www.java2s.com/Code/JavaScript/Table/TableCellbackgroundColorExample.htm[^]

http://blogs.sitepoint.com/background-colors-javascript/[^]


这篇关于如何为我的标题添加bg颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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