<script type="text/javascript"> (function(){ if(document.getElementById("TH") == "TH"){ alert("Hello"); } })();</script><input id="TH" type="text">
if( ($("#yupyup").length) > 0 ) { alert('hello');}
http://codepen.io/ggilmore/pen/5/1
You can check to see if a div exists like this: