[英]hide column in display table
有什么辦法可以隱藏顯示表的列,我們有media =“ none”來隱藏列。我嘗試使用
document.getElementById(display_column_name).media="none";
但它不起作用,我在設置javascript中顯示列的attritube時卡住了。由於按鈕選擇列是隱藏/顯示表的顯示。
我在列標題上具有復選框。我必須隱藏顯示表的列。單擊按鈕時隱藏選定的列。
我也嘗試過使用div標簽顯示列
<div id= "col1" style="display:block">
<display:column paramId="date_disp" paramName="date_disp" property="date_disp" title="Date" sortable="true" headerClass="sortable" decorator="com.commons.ColDateDecorator" style="font-family:Arial, Helvetica, sans-serif;font-size: 12px;height: 25;"/>
</div>
和document.getElementById('col1')。style.display =“ none”; 但它不起作用。
是要隱藏的元素還是多個元素? document.getElementsByName將返回一個元素數組,因此您需要像這樣訪問它:
document.getElementsByName(display_column_name)[0] .media =“ none”
如果只是一個元素並且該元素具有ID,請考慮使用以下方法:
getElementById()
我也假設display_column_name是一個先前定義的變量,對嗎?
最好的方法是將css顯示樣式設置為none。
document.getElementById("id _of_the_component").style.display = 'none';
或者,您可以使用jquery庫,但必須從jquery.com下載jquery庫。 使用script標簽將腳本導入您的頁面,然后執行以下操作
$("#id _of_the_component).hide();
請嘗試以下操作:
HTML:
<html>
<table>
<tr>
<td id="td1">TD1</td>
<td id="td2">TD2</td>
<td id="td3">TD3</td>
</tr>
</table>
</html>
JavaScript:
document.getElementById("td2").style.display = "none";
Uchenna是正確的,您可以使用jQuery庫
使用腳本標記將腳本導入頁面
向要隱藏的列添加屬性“ id”或“ class”
並使用該類或ID可以隱藏該元素。
例如。 如果您具有提及的id屬性,並且valuse為“ abc”
那么你可以寫:
$(document).ready(function()
{
$("#abc").hide();
});
修改顯示列,例如:
<display:column class="abc" paramId="date_disp" paramName="date_disp" property="date_disp" title="Date" sortable="true" headerClass="sortable" decorator="com.commons.ColDateDecorator" style="font-family:Arial, Helvetica, sans-serif;font-size: 12px;height: 25;"/>
在按鈕上單擊,您可以編寫:可以說您正在使用按鈕
<input type="submit" value="Submit" id="success" />
then you can use it like :
$('#success').click(function(){
$(".abc").hide();
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.