var dialog = (function(){ var mydialog = function(){}; mydialog.show = function(info){ kk = document.createElement("div");//爲何這裏不能加va? document.body.appendChild(kk) kk.innerHTML = info+"<button type='button' value='close'></button>"; kk.childNodes[1].onclick = mydialog.close; kk.className = "center"; } mydialog.close = function(){//這種寫法是什麼知識點? document.body.removeChild(kk) } return mydialog; })(); window.show = dialog.show;