title: Detect a Variable Exists in jQuery
body: <p>Hello I am rather new to jQuery and have a situation here.</p>
  
  <p>I am actually setting default position on document.ready as below</p>
  
  <pre><code>$('.categorytitle').scrollTo($(".people .sants a.modeling").attr('href'), 750, {easing:'easeOutExpo'});
  </code></pre>
  
  <p>now this works perfectly when this is placed on the page containing .categorytitle class</p>
  
  <p>The issue arises when the script cannot find .categorytitle class in the document</p>
  
  <p>I tried the below code but it did not work</p>
  
  <pre><code>if($('.categorytitle').length!= 0){
       $('.categorytitle').scrollTo($(".people .sants a.modeling").attr('href'), 750, {easing:'easeOutExpo'});
  }
  </code></pre>
  
  <p>Can anyone help on a way I can find if .categorytitle exists in the page?</p>
  
  <p>Many thanks!</p>
  
  <p>This is the complete code I am trying to implement.</p>
  
  <pre><code>        if($('.categorytitle').length){
          $('.categorytitle').scrollTo($(".people a.modeling").attr('href'), 750, {easing:'easeOutExpo'});
          }
          if($('.categorytext').length){
          $('.categorytext').scrollTo($(".people a.modeling").attr('href'), 750, {easing:'easeOutExpo'});
          }
          if($('.models').length){
          $('.models').scrollTo($(".people a.modeling").attr('href'), 750, {easing:'easeOutExpo'});
          }
  </code></pre>
  
  <p>I get "f is undefined" is the jQuery ScrollTo Script file. Seems like the $(".people .sants a.modeling").attr('href') is undefined and so this error.</p>