jquery onReady 異常中斷問題

<!Doctype> javascript

<html>
<script type="text/javascript" src="jquery-1.8.0.js"></script>
<body></body>
<script>
$(function(){
console.log(1)//  1處 始終不受影響
})  

</script> html


<script>
$(function(){
   
a.a=2;//這裏a 沒有定義,出現一個異常那麼下方的2處也不會執行。

})  
</script>


<script>
$(function(){
  console.log(2)//  2處

}) java

console.log(3)//3處始終 不受影響 jquery

</script>

</html> spa

 ============================ htm

這樣就會有個坑爹的問題你覺得你 js 代碼 是獨立分開的,誰知前邊某個地方(也許是引入的某個基於jquery onReady 執行的第三方庫)的發生了異常,就致使你後邊的 jquery onReady 方法中的 代碼 未執行 ip

相關文章
相關標籤/搜索