title: JScript Check if element exists and remove it
body: <p>I'm trying to write a simple function in javascript to check if an element exists in the DOM and if it does remove, and if it doesn't, append it to the page, so far i've got this</p>
  
  <pre><code>        if document.contains(document.getElementById("submitbutton") {
              document.getElementById("submitbutton").remove();
  }   else {
          lastDiv.appendChild(submitButton);  
          }
  </code></pre>
  
  <p>(lastDiv is just the div I want to append the div 'submitButton' to)
  Yet i'm getting the error "Uncaught ReferenceError: myFunction is not defined"</p>
  
  <p>Any help?
  I'm aware this is a very newbie question, sorry about that</p>