stop function running if selector does not exist - jquery?
<p>I am trying to stop my autoBike(); bike function running if my <code>#bike-main-slider div.bike</code> data-bike attribute value does not exist.</p>

<pre><code>&lt;script&gt;

    var bike = '&lt;?=(isset($_REQUEST['bike']) ? htmlentities($_REQUEST['bike']) : null)?&gt;';

    autoBike = function () {

         var bikeIndex = $('#bike-main-slider div.bike[data-bike=' + bike + ']').index();

         mainSlider.goToSlide(bikeIndex);  

    };

    autoBike();

&lt;/script&gt;

&lt;div id="slideshow"&gt;

     &lt;div class="bike" data-bike="50cc"&gt;&lt;/div&gt;
     &lt;div class="bike" data-bike="100cc"&gt;&lt;/div&gt;
     &lt;div class="bike" data-bike="150cc"&gt;&lt;/div&gt;
     &lt;div class="bike" data-bike="200cc"&gt;&lt;/div&gt;
     &lt;div class="bike" data-bike="250cc"&gt;&lt;/div&gt;
     &lt;div class="bike" data-bike="350cc"&gt;&lt;/div&gt;

&lt;/div&gt;
</code></pre>

<p><br /></p>

<p>Is this possible?</p>

<p>So for example if my URL is...</p>

<p><strong>http://example.com/?bike=450cc</strong></p>

<p>and as you can see no 450cc exists in my #slideshow divs, so is there anyway to prevent my <code>autoBike();</code> function running if data-bike attribute value does not exist?</p>

<p>Using jQuery</p>

<p><br /></p>

<p>Thanks</p>
