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]); } }