while循環在我的網頁我有以下幾點:jQuery的while循環,使瀏覽器崩潰
<script>
$(document).ready(function(){
var height = $("#quote").height();
//alert("Toegestane hoogte: 500px\nHuidige hoogte: "+height+"px");
while (height > 500) {
var fontSize = $('p', $('#quote')).css('font-size').split('px')[0];
var fontInt = parseInt(fontSize) - 1;
fontInt = fontInt + 'px';
$('p', $('#quote')).css('font-size', fontInt);
}
});
不知怎的,當我加載頁面時,瀏覽器會持續打開,並最終崩潰......
您必須更新的高度永遠不會增加**在循環。該循環如何暫停? –
@dystroy你應該張貼作爲回答 – anurupr
使用,而不是在代碼中while。我認爲如果(身高> 500)將完成這項工作 –