Closed JamesChan0107 closed 2 months ago
HW4:https://github.com/JamesChan0107/JamesChan0107.github.io/blob/main/HW4.md Question: 我發現我在寫script時,習慣寫成一長串且不愛設變數(ex.寫顯示鈕:document.getElementById('show').addEventListener('click',function(){document.getElementById('img').style.display = 'block';}),請問這習慣是否要去改?以及想了解依據您的經驗,哪些習慣要盡量培養,對未來coding有幫助呢?
A1: 要改掉,因為有時候會移除元素 ex: 彈出視窗 document.getElementById() 不是每次都取的到DOM元素,抓不到會掛掉
A2: 入門的習慣培養:
HW4:https://github.com/JamesChan0107/JamesChan0107.github.io/blob/main/HW4.md Question: 我發現我在寫script時,習慣寫成一長串且不愛設變數(ex.寫顯示鈕:document.getElementById('show').addEventListener('click',function(){document.getElementById('img').style.display = 'block';}),請問這習慣是否要去改?以及想了解依據您的經驗,哪些習慣要盡量培養,對未來coding有幫助呢?