The <!-- and //--> comment (hiding) tags have not been necessary since IE3 (i.e. since September 1997). If you see these in some published script it is a warning that you are looking at ancient and perhaps unreliable code.
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.