xxxxxxxxxx
// 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);
}
xxxxxxxxxx
in .html page
add .js file script at the bottom instead of in the header
******************
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="myfile.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Api</title>
</head>
<body>
</body>
<script src="my.js"></script> ======> here
</html>
xxxxxxxxxx
if(cInputValue.value != "")