本文目录一览

1,js如何获取动态生成的table的高度

等table全部生成完以后再取,可以通过回调函数来解决如果需要实时取,可以用setInterval,每一段时间取一次
var count = $("#sample_1").children().length;<br>alert(count);

js如何获取动态生成的table的高度

2,JS能否获取动态class的宽度并赋值给高度目的是实现响应式正方形

你这样的写的话 不先赋值给thumbnail统一的高度的话恐怕页面会显得参差不齐而不是你想的4块模块平均撑开页面,还有你是把图片写进div你当背景,那就不需要js来处理这个问题。 <style> #thumbnailbox{position: absolute;left:0;top:0;width:100%;height:100%;} #thumbnailbox a{width:50%;height:50%;display:block;position:absolute;left:0;top:0;} #thumbnailbox a.bg1{background:url(../images/1.jpg) 50% 50% no-repeat;} #thumbnailbox a.bg2{left:50%;background:url(../images/2.jpg) 50% 50% no-repeat;} #thumbnailbox a.bg3{top:50%;background:url(../images/3.jpg) 50% 50% no-repeat;} #thumbnailbox a.bg4{left:50%;top:50%;background:url(../images/4.jpg) 50% 50% no-repeat;} </style> <div id="thumbnailbox"> <a href="post_1.html" title="缩略图1" class="thumbnail bg1"></a> <a href="post_1.html" title="缩略图1" class="thumbnail bg2"></a> <a href="post_1.html" title="缩略图1" class="thumbnail bg3"></a> <a href="post_1.html" title="缩略图1" class="thumbnail bg4"></a> </div>
为什么缩略图非要用背景图片的方式?背景图片是无法设置宽度的。直接把图片写入div中不可以吗?然后给IMG设置css就可以了呀。

JS能否获取动态class的宽度并赋值给高度目的是实现响应式正方形


文章TAG:怎么  获取  动态  高度  js怎么获取动态高度  
下一篇