① js給動態創建的按鈕添加動態事件
這是源JavaScript經典的閉包問題
你需要
document.getElementById('king'+i).onclick=function(i){ returnfunction() { document.getElementById('shipin').src=arr[i] }}(i)