我在一些論壇上看到,禁用html表格是爲了添加一層div。我的問題是我不知道該怎麼做。如何使HTML看起來被禁用?
我有3個問題:
1)我將如何設置DIV的高度,它會自動調整表高度每當表增加了它的高度時,增加了一個新的行。
2.)我將如何讓div覆蓋表格。我不知道如何分層html元素。
3.)當我點擊'禁用'按鈕並點擊'啓用'按鈕後再次啓用它,我該如何編寫JavaScript代碼,以使我的表格看起來被禁用。
tabledisabletest.html
<html>
<head>
<script type="text/javascript">
</script>
<style type="text/css">
table#tblTest {
width: 100%;
margin-top: 10px;
font-family: verdana,arial,sans-serif;
font-size:12px;
color:#333333;
border-width: 1px;
border-color: #666666;
border-collapse: collapse;
}
table#tblTest tr.highlight td {
background-color: #8888ff;
}
table#tblTest tr.normal {
background-color: #ffffff;
}
table#tblTest th {
white-space: nowrap;
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #666666;
background-color: #dedede;
}
table#tblTest td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #666666;
background-color: #ffffff;
}
#disabler {
width: 100%;
height: 200px;
background-color: #bbb;
opacity:0.6;
}
</style>
</head>
<body>
<div id="disabler"></div>
<table id="tblTest">
<thead>
<tr>
<th>Name</th>
<th>Address</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tom</td>
<td>UK </td>
</tr>
<tr>
<td>Henrik</td>
<td>Denmark</td>
</tr>
<tr>
<td>Lionel</td>
<td>Italy</td>
</tr>
<tr>
<td>Ricardo</td>
<td>Brazil</td>
</tr>
<tr>
<td>Cristiano</td>
<td>Portugal</td>
</tr>
</tbody>
</table>
<input type="button" onclick="disable = true;" value="Disable" />
<input type="button" onclick="disable = false;" value="Enable" />
</body>
</html>
我有DIV disabler
做禁用,但我不能讓它覆蓋表。
請幫我這個。我對這件事很陌生。提前致謝。
建議:使用jQuery BlockUI 。演示:http://jquery.malsup.com/block/#demos – Dev
我想我需要先學習本地JavaScript,然後再跳入某些高級技術。此外,我需要學習JavaScript,因爲我需要準備考試。 – NinjaBoy
究竟是什麼意思,使其*看起來禁用*?用戶還可以從中選擇文本嗎?它是否需要在禁用控件上看到這些邊框和陰影效果? –