I've seen other posts with the same title. Why does jQuery or a DOM method such as getElementById not find the element? does not apply. I am not looking for the ID before the html is loaded. Here is the whole file:
https://jsfiddle.net/2uxqmsth/ If you click on the link - the function is called. The relevant javascript is below:
function getNewComment() {
var xd = document.getElementById('#xdialog');
if ( xd === null ) alert( 33 );
else alert( 22 );
}