導航:首頁 > 編程語言 > js設置table寬度

js設置table寬度

發布時間:2023-09-26 04:01:01

❶ 求拖動改變table行高,列寬的js或者jquery

<!doctypehtml>
<htmllang="en">
<head>
<metacharset="utf-8"/>
<title>jQueryUIResizable-Defaultfunctionality</title>
<linkrel="stylesheet"href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"/>
<scriptsrc="http://code.jquery.com/jquery-1.9.1.js"></script>
<scriptsrc="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<linkrel="stylesheet"href="/resources/demos/style.css"/>
<style>
#resizable{width:150px;height:150px;padding:0.5em;}
#resizableh3{text-align:center;margin:0;}
</style>
<script>
$(function(){
$("#resizable").resizable();
});
</script>
</head>
<body>
<divid="resizable"class="ui-widget-content">
<h3class="ui-widget-header">Resizable</h3>
</div>
</body>
</html>

可以下載一個jquery UI的插件,裡面有一個Resizable方法,不僅僅可以改變列寬,還可以行寬。

❷ 如何用 js 獲取table 或者其他塊狀標簽的 寬和高

以table為例,首先為其設計class或者id如:id為table
然後進入js中
定義一個對象
var table=document.getelementbyid("table")
這是獲取這個元素
然後寬和高
就是table.width
table.height

❸ 用js怎麼設置在table的cell里插入的textbox的寬度,也就是width值

row.cells[4].setAttribute("size","20")

❹ js獲取table中的td寬度並賦值到另一個table的td中,實現寬度對齊

給你說下思路,
document.getElementById("top").rows.length可以獲得top表的行數
document.getElementById("top").rows[0].cells.length可以獲得top表的第一行的列版數
document.getElementById("top").rows[0].cells[0].offsetWidth可獲得top表第一行第一列權的實際寬度,(注意,這個是只讀的!)

所以
for(var i=0;i<document.getElementById("top").rows[0].cells.length;i++)
{
document.getElementById("buttom").rows[0].cells[i].width=document.getElementById("top").rows[0].cells[i].offsetWidth;
}
希望對你有幫助!

❺ js中如何取到table中某一列的寬度

從欄位名稱看得出,寬度變化比較大的就是籍貫了,建議你將table的寬度設置成100%,然後裡面列不要設置寬度,讓其自適應.如果不想td中的文字換行,可以在CSS中控制:

td{white-space:nowrap}

如果要獲取寬度可以用以下js

<tablewidth="300"border="1">
<tr>
<td>firsttd</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<tdid="c2">td{white-space:nowrap}</td>
<td>&nbsp;</td>
</tr>
</table>
<scriptsrc="http://libs..com/jquery/2.0.0/jquery.min.js"></script>
<script>
alert($("tabletr:firsttd:eq(0)").width());//獲取tr第1列的寬度
alert($("#c2").width())//獲取指定ID的td寬度
</script>

❻ 如何設置HTML頁面自適應寬度的table

用jquery獲取瀏覽器實時的寬度,然後設置table寬度
<body onload="resize();" onresize="resize();">
<table>
<thead>
<th>col1</th>
<th>col2</th>
</thead>
<tbody>
<tr>
<td>我是帥哥</td>
<td>樓上說的很對</td>
</tr>
</tbody>
</table>

<script src="js/JQuery.min.js"></script> //別忘了引入內JQeury的js文件
<script>
function resize() {
var width = $(document).width() ; //獲取瀏覽器寬度
$("table").width(width) ; //設置容table寬度
}
</script>
</body>

閱讀全文

與js設置table寬度相關的資料

熱點內容
名片模板word 瀏覽:635
怎麼把文件夾上鎖 瀏覽:331
我不會英語怎麼編程 瀏覽:895
c盤和文件大小 瀏覽:63
maya工具架怎麼調出來 瀏覽:191
文件系統壞了怎麼辦 瀏覽:261
小公司網路布線 瀏覽:515
怎麼用二維碼編程 瀏覽:341
f9b文件能用手機看嗎 瀏覽:364
手機暴風視頻文件夾 瀏覽:394
vsftpdlinux下載文件 瀏覽:948
文件名修改後快捷方式還可以用嗎 瀏覽:387
親密愛人qq相冊名字 瀏覽:884
怎麼修改手機原始密碼 瀏覽:230
榆次網站優化怎麼樣 瀏覽:537
vb窗體文件如何打開 瀏覽:810
百度找圖怎麼跳轉網站 瀏覽:284
安卓44如何隱藏文件夾 瀏覽:92
sr100怎麼編程序 瀏覽:795
蘋果手機怎樣保存信息 瀏覽:379

友情鏈接