This is one of the most commonly used piece of code for jQuery. Often times, we need to check if a div/element exists in the page before processing a block of script (eg: replacing the content of the div).
if ( $("#message").length ) { $('#message').text("Hello!"); }