📅  最后修改于: 2022-03-11 14:56:53.191000             🧑  作者: Mango
// Credit to: Rob M.
// Origin: https://stackoverflow.com/questions/26107125/cannot-read-property-addeventlistener-of-null
// I think the easiest approach would be to just
// check that el is not null before adding an event listener:
var el = document.getElementById('overlayBtn');
if(el){
el.addEventListener('click', swapper, false);
}