原諒我的壞名字,但現在,我甚至不知道我不知道什麼。在阻止代碼之前和之後做一些事情
如果我有一個HTML頁面,看起來是這樣的:
<html>
<head>
<script>
jQuery(document).ready(function(){
jQuery("#modalDiv").show();
//This part takes up to a few seconds to execute and blocks the browser
for(var i = 0; i < 10000; i++){
console.log("doing something");
}
jQuery("#modalDiv").hide();
});
</script>
<style>
#modalDiv{
background-color:red;
height:100px;
width:100px;
}
</style>
</head>
<body>
<div id="modalDiv"></div>
</body>
</html>
ID爲「modalDiv」元素是永遠不會顯示在頁面上。我沒有試圖解決這個「問題」,我只是想了解引擎蓋下發生了什麼,導致我的腳本像它一樣行事。
你在你的DOM稱爲#modalDiv一個div? – Gallen
使用Firebug檢查DOM。 –
你的控制檯告訴你什麼? –