0
我想在发送到打印机之前找到一种方法来发送自己的警报,如果任何div大于预设大小。获取页面上所有div ID的高度
每个页面将有所不同,并有不同的样本测试问题的div ID。
此外,每个div的高度不会像预先设置的那样高。 目前,我有这个,但它不工作,我会希望:
<style>
#one{background:#ddd;height:250px;}
#two{background:#000;height:300px;}
</style>
<div id="page">
<div id="one">
stuff
</div>
<div id="two">
more stuff
</div>
</div>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script>
var IDs = $("#page div[id]")
.map(function() { return this.id; })
var result = $(this.id).height();
if(result > 275){
alert("over");
}else{
alert("under");
}
</script>
我确实觉得我靠近。任何帮助是极大的赞赏。
为什么你得到一组ID,然后从来没有使用它?也许你应该看看['each'](https://api.jquery.com/each/)方法。 –