JavaScript設(shè)置FieldSet展開與收縮
更新時(shí)間:2009年05月15日 00:02:17 作者:
JavaScript設(shè)置FieldSet展開與收縮實(shí)現(xiàn)代碼。
JavaScript方法代碼:
// 設(shè)置FieldSet高度方法,支持IE瀏覽器、Firefox
// 參數(shù)1:pTableID,F(xiàn)ieldSet內(nèi)部div或table的id
// 參數(shù)2:pFieldSetID,F(xiàn)ieldSet的ID
// 參數(shù)3:pImageID,圖片的ID,展開或收縮后更新圖片SRC
function FieldSetVisual( pTableID, pFieldSetID, pImageID )
{
var objTable = document.getElementById( pTableID ) ;
var objFieldSet = document.getElementById( pFieldSetID) ;
var objImage = document.getElementById( pImageID) ;
if( objTable.style.visibility == 'visible' )
{
objTable.style.visibility = 'hidden' ;
objFieldSet.style.height = "22px" ;
objImage.src="images/expand.png" ;
}
else
{
objTable.style.visibility = 'visible';
var heightFieldSet = parseInt( objFieldSet.style.height.substr(0,objFieldSet.style.height.length-2)) ;
var heightTable = parseInt( objTable.offsetHeight ) ;
objFieldSet.style.height = heightFieldSet + heightTable + "px" ;
objImage.src="images/constringency.png" ;
}
}
HTML中FieldSet代碼:
<fieldset id="fset_ShipInportInfo">
<legend>
<img alt="展開或收縮" id="img_ShipInportInfo" src="images/constringency.png" src="images/constringency.png" onclick="FieldSetVisual('t_ShipInportInfo','fset_ShipInportInfo','img_ShipInportInfo')" />車船到廠記錄<span style="color: Red;" style="color: Red;">(已錄入/未錄入)</span></legend>
<table width="100%" border="0" cellpadding="0" cellspacing="0" id="t_ShipInportInfo"
style="visibility: visible;" style="visibility: visible;">
<tr>
<td>
車船名:<span style="font-weight: bold;" style="font-weight: bold;">車皮 等 共50節(jié)</span>
</td>
<td>
車船到達(dá)時(shí)間:2009年5月9日 17時(shí)
</td>
<td>
來煤方式:<span style="font-weight: bold;" style="font-weight: bold;">鐵路</span>
</td>
<td>
煤炭來源:<span style="font-weight: bold;" style="font-weight: bold;">淮南</span>
</td>
</tr>
</tr>
</table>
</fieldset>
復(fù)制代碼 代碼如下:
// 設(shè)置FieldSet高度方法,支持IE瀏覽器、Firefox
// 參數(shù)1:pTableID,F(xiàn)ieldSet內(nèi)部div或table的id
// 參數(shù)2:pFieldSetID,F(xiàn)ieldSet的ID
// 參數(shù)3:pImageID,圖片的ID,展開或收縮后更新圖片SRC
function FieldSetVisual( pTableID, pFieldSetID, pImageID )
{
var objTable = document.getElementById( pTableID ) ;
var objFieldSet = document.getElementById( pFieldSetID) ;
var objImage = document.getElementById( pImageID) ;
if( objTable.style.visibility == 'visible' )
{
objTable.style.visibility = 'hidden' ;
objFieldSet.style.height = "22px" ;
objImage.src="images/expand.png" ;
}
else
{
objTable.style.visibility = 'visible';
var heightFieldSet = parseInt( objFieldSet.style.height.substr(0,objFieldSet.style.height.length-2)) ;
var heightTable = parseInt( objTable.offsetHeight ) ;
objFieldSet.style.height = heightFieldSet + heightTable + "px" ;
objImage.src="images/constringency.png" ;
}
}
HTML中FieldSet代碼:
復(fù)制代碼 代碼如下:
<fieldset id="fset_ShipInportInfo">
<legend>
<img alt="展開或收縮" id="img_ShipInportInfo" src="images/constringency.png" src="images/constringency.png" onclick="FieldSetVisual('t_ShipInportInfo','fset_ShipInportInfo','img_ShipInportInfo')" />車船到廠記錄<span style="color: Red;" style="color: Red;">(已錄入/未錄入)</span></legend>
<table width="100%" border="0" cellpadding="0" cellspacing="0" id="t_ShipInportInfo"
style="visibility: visible;" style="visibility: visible;">
<tr>
<td>
車船名:<span style="font-weight: bold;" style="font-weight: bold;">車皮 等 共50節(jié)</span>
</td>
<td>
車船到達(dá)時(shí)間:2009年5月9日 17時(shí)
</td>
<td>
來煤方式:<span style="font-weight: bold;" style="font-weight: bold;">鐵路</span>
</td>
<td>
煤炭來源:<span style="font-weight: bold;" style="font-weight: bold;">淮南</span>
</td>
</tr>
</tr>
</table>
</fieldset>
您可能感興趣的文章:
- JS+CSS實(shí)現(xiàn)DIV層的展開、收縮效果
- js實(shí)現(xiàn)div層緩慢收縮與展開的方法
- vuejs實(shí)現(xiàn)折疊面板展開收縮動(dòng)畫效果
- JS右下角廣告窗口代碼(可收縮、展開及關(guān)閉)
- JS實(shí)現(xiàn)固定在右下角可展開收縮DIV層的方法
- 在iframe里的頁面編寫js,實(shí)現(xiàn)在父窗口上創(chuàng)建動(dòng)畫效果展開和收縮的div(不變動(dòng)iframe父窗口代碼)
- JS仿QQ好友列表展開、收縮功能(第一篇)
- JS仿QQ好友列表展開、收縮功能(第二篇)
- Vue.JS實(shí)現(xiàn)垂直方向展開、收縮不定高度模塊的JS組件
- JavaScript實(shí)現(xiàn)QQ列表展開收縮擴(kuò)展功能
- javascript使用substring實(shí)現(xiàn)的展開與收縮文字功能示例
相關(guān)文章
html5+canvas實(shí)現(xiàn)支持觸屏的簽名插件教程
jq-signature.js是一個(gè)幫助你創(chuàng)建簽名的jQuery插件,允許你的用戶使用鼠標(biāo),手指或者鉛筆生成簽名。下面這篇文章主要給大家介紹了利用html5+canvas實(shí)現(xiàn)支持觸屏的簽名插件的相關(guān)資料,需要的朋友可以參考下。2017-05-05js+html+css實(shí)現(xiàn)簡(jiǎn)單電子時(shí)鐘
這篇文章主要為大家詳細(xì)介紹了js+html+css實(shí)現(xiàn)簡(jiǎn)單電子時(shí)鐘,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-06-06js與jQuery實(shí)現(xiàn)獲取table中的數(shù)據(jù)并拼成json字符串操作示例
這篇文章主要介紹了js與jQuery實(shí)現(xiàn)獲取table中的數(shù)據(jù)并拼成json字符串操作,涉及javascript與jQuery針對(duì)HTML頁面table表格數(shù)據(jù)獲取、遍歷及json字符串拼接相關(guān)操作技巧,需要的朋友可以參考下2018-07-07關(guān)于微信jssdk實(shí)現(xiàn)多圖片上傳的一點(diǎn)心得分享
這篇文章主要介紹了關(guān)于微信jssdk實(shí)現(xiàn)多圖片上傳的一點(diǎn)心得分享,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-12-12收藏,對(duì)比功能的JS部分實(shí)現(xiàn)代碼
非常不錯(cuò)的,收藏效果代碼,增加當(dāng)前頁的現(xiàn)實(shí),實(shí)現(xiàn)對(duì)比2008-08-08通過JS自動(dòng)隱藏手機(jī)瀏覽器的地址欄實(shí)現(xiàn)原理與代碼
大家通過手機(jī)自帶瀏覽器打開百度、淘寶,在首頁加載完畢后,會(huì)自動(dòng)隱藏頁面上方的地址欄,感興趣的朋友可以參考下2013-01-01JS實(shí)現(xiàn)網(wǎng)頁標(biāo)題隨機(jī)顯示名人名言的方法
這篇文章主要介紹了JS實(shí)現(xiàn)網(wǎng)頁標(biāo)題隨機(jī)顯示名人名言的方法,涉及JavaScript中字符串、數(shù)組及隨機(jī)數(shù)的相關(guān)操作技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-11-11