1. 请教js如何实现让table的表头的高度固定
方法<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<META http-equiv="Content-Style-Type" content="text/css">
</head>
<script language=javascript>
var t, n, c;
window.onload=function(){
t = document.getElementById("tb");
t.rows[0].style.height="50px" //在这里设置高专度属
}
2. jtable 显示表头
不懂你的问题,一般都是
JScrollPane js=new JScrollpane();
js.setViewPortView(table);//将table加到jscrollpane里面去,保证当位置不够时,出现滚动条
panel.add(js);
3. 如何让table 表头随着滚动条滚动 达到覆盖效果。 JS 、JQ大神求帮忙。
建议用DIV代替表头,直接用table的话可能不行,楼下说的对就是用fixed,但是不版是一上来就用fixed而是等到你权的表格头部到浏览器顶端的时候才用fixed,去网络一下JS或则JQ的吸顶效果吧~会有你想要的~
4. 我想在jsp里面用标签<table>写一个表格,怎么可以实现让表格的表头是动态的
把js代码写到表头位置,for循环days[i]=i+1;替换成表头的html代码document.write("<th>day[i]</th>");
5. js怎样获得table样式
创建和插入例子,按需自改
/** * 创建表格 * id 为表格id * arr 为表格表头 */ function createTable(id,arr){ var table = document.createElement('table'); table.setAttribute("id",id); table.setAttribute("className","TableLine");//设定样式 table.setAttribute("width",'98%'); table.setAttribute("cellpadding",'3'); table.setAttribute("cellspacing",'0'); var row = table.insertRow(); row.style.setAttribute("backgroundColor","#e0e0e0"); for (var i = 0; i < arr.length; i++) { var col = row.insertCell(); if(i==0){ col.setAttribute("width",'3%'); } col.setAttribute("className","border:1px solid #9BC2E0;"); col.setAttribute("align","center"); col.style.fontSize="13px"; col.style.fontWeight="Bold";; //var style = document.createAttribute("styles"); //style.nodeValue = "font-size:large"; //col.setAttributeNode(style); col.innerHTML = arr[i]; } //alert(table.outerHTML); return table; }
/** * 向表格插入一行 */ function addRow(table,id,arr){ var row = table.insertRow(); row.setAttribute("id",id); row.onclick=function (){}; for(var i=0;i<arr.length;i++){ var col = row.insertCell(); col.innerHTML = arr[i]; //col.innerText = arr[i]; col.setAttribute("title",arr[i]); } }