How do I use (or mimic) document.getElementById() on a page loaded from WordPress database?

WordPress uses wp_enqueue_script() to register and enqueue javascript contained in a separate file. The default behavior is for wp_enqueue_script() is to load the script before the </body> tag, and apparently WordPress pages require the script to be loaded in the footer. As pointed out in the comments, the clue to this problem with the loading sequence was in the TypeError that the document.body was null.

Once the wp_enqueue_script() $in_footer option was set to true, the original javascript ran as expected and binding to the page occurred. This change was only required for the public side page, and was not required for the admin side page included into WordPress.