Wasn't timing related - moving the element ahead of the script block to see if that helps.