I created a .js file for the directory of html of files I am working with. The purpose of the .js file is to remove element ids. So in my .js file I currently have the script
var element=document.getElementById("id1");
element.parentElement.removeChild(element);
which works perfectly fine and does what I need to do. Now If I was to include an additional script to remove the id element of a different html page
var element = document.getElementById("id1");
element.parentElement.removeChild(element);
var elem = document.getElementById("id2");
elem.parentElement.removeChild(elem);
Only the first script is executed and the second is not in addition I receive the message "Uncaught type error: cannot read 'parentElement' of null. I would think that each html page would read the .js file and match the corresponding element it is referring too and make the change.