title: Execute the jquery code only if div exist
body: <p>here is the html code : </p>
  
  <pre><code>&lt;div id="popup" class="popup_block" &gt;
   &lt;img src="images/PUB-histRIRE.jpg" alt="popup" /&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>and script : </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(document).ready(function(){
  
              popWidth = 690;
              popHeight = 550;
              popID = 'popup';
  
              var popMargTop = popHeight / 2;
              var popMargLeft = popWidth / 2;
  
              //Apply Margin to Popup
              $('#' + popID).css({ 
                  'width': popWidth,
                  'height': popHeight,
                  'margin-top' : -popMargTop,
                  'margin-left' : -popMargLeft,
                  'visibility' : 'visible'
              }); 
  
              //Fade in Background
              $('body').append('&lt;div id="fade"&gt;&lt;/div&gt;'); //Add the fade layer to bottom of the body tag.
              $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer 
  
          //Close Popups and Fade Layer
          $('a.close, #fade, .popup_block').live('click', function() { //When clicking on the close or fade layer...
              $('#fade , .popup_block').fadeOut(); //fade them both out
              $('#fade').remove();
              return false;
          }); 
  
      });
      &lt;/script&gt;
  </code></pre>
  
  <p>I like to execute the code only on page with the div... on page without thi div, just ignore. I can make a if by parsin the URL... but it look more complicated to me... any simple jquery trick ?</p>