社区
JavaScript
帖子详情
请教,如何获取style.display=none表单的宽高数据?
drifters
2004-10-12 04:51:33
例如表单
================================
<select id="test" style="display:none">
<option>a</option>
<option>a</option>
</select>
如何动态获得它的宽,而无需先把它显示出来。
谢谢
...全文
116
4
打赏
收藏
请教,如何获取style.display=none表单的宽高数据?
例如表单 ================================ a a 如何动态获得它的宽,而无需先把它显示出来。 谢谢
复制链接
扫一扫
分享
举报
写回复
配置赞助广告
4 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
tianch
2004-10-13
打赏
举报
回复
不用display=none,这样取不到宽高
改用visibility=hidden 可以用以下的方法取到宽高
<body onLoad="alert(test.offsetWidth+"\n"+test.offsetHeight);">
<select id="test" style="visibility: hidden">
<option>a</option>
<option>a</option>
</select>
</body>
meizz
2004-10-13
打赏
举报
回复
先显示, 用clientWidth等取宽, 再用display="none"将其隐藏
drifters
2004-10-13
打赏
举报
回复
如不指定宽呢?
ttyp
2004-10-12
打赏
举报
回复
<select id="test" style="display:none;width:90" width=80 >
<option>a</option>
<option>a</option>
</select>
<SCRIPT LANGUAGE="JavaScript">
<!--
alert(document.all.test.style.width);
alert(document.all.test.width);
//-->
</SCRIPT>
//这个事先指定了宽
相关推荐
解决echarts显示隐藏
宽
度发生变化
解决方法:先给ehcarts赋值
高
宽
,再隐藏。 js $("#map").css({"width":$("#map").width(),"height":$("#map").height()}); //隐藏之前先设置
高
、
宽
,防止出现100px document.getElementById("mapDiv").
style
.
display
= "none"; 示echarts时再重新赋值
高
宽
: $("#map").css({"width":
js点击下拉菜单申请a3_DIV+CSS+JS仿Select下拉
表单
网页特效源代码下载
DIV+CSS+JS仿Select下拉
表单
DIV+CSS+JS仿下拉
表单
function $$$$$(_sId){return document.getElementById(_sId);}function hide(_sId){$$$$$(_sId).
style
.
display
= $$$$$(_sId).
style
.
display
== "none" ? "" : "none";}functi...
设置Iframe窗体大小
//在子窗体中,子窗体操作父窗体元素 ‘loadimg’为父窗体元素编号 parent.document.getElementById('loadimg').
style
.
display
='none'; //在子窗体中,设置父窗体的IFrame的
高
和
宽
parent.document.getElementsByTagName('iframe')[0].height=document....
获取
display
:none的元素的
宽
度和
高
度
display
为none的元素不能通过offsetWidth和offsetHeight来
获取
宽
高
(未参与css渲染), 解决方案:可以通过在
display
为none的元素使用行内样式
style
设置
宽
高
,通过
style
.width 和
style
.height
获取
, 注意:样式不能写字css文件中。否则
获取
不到 转载于:https://www.cnblogs.com/renbo/p/8977880...
发帖
JavaScript
JavaScript
Web 开发 JavaScript
复制链接
扫一扫
8.7w+
社区成员
22.4w+
社区内容
Web 开发 JavaScript
社区管理员
加入社区
获取链接或二维码
帖子事件
创建了帖子
2004-10-12 04:51
社区公告
暂无公告