Your first one was basically right. This, FYI, is bad. It does an equality check between a DOM node and a string:
if (document.getElementById('customx') == ""){
DOM nodes are actually their own type of JavaScript object. Thus this comparison would never work at all since it's doing an equality comparison on two distinctly different data types.