jQuery cycle + if/else show/hide div

jQuery cycle + if/else show/hide div

I'm using the jQuery cycle plugin...what I'd like to do is check if an image contained within div#slideshow has a class of "before"...if said image does have that class, I'd like to show a div with a class of before, if not, then hide the div.before make sense? In the example, image-1 would show the div.before, image-2 would hide it. 

Any thoughts?

  1. <div class="before"></div>
  2. <div id="slideshow">
  3.       <img class="before" src="image-1.jpg">
  4.       <img src="image-2.jpg">
  5. </div>


  6. <script type="text/javascript" charset="utf-8">
  7. $(document).ready(function(){
  8. if ($('#slideshow img').hasClass('before') {
  9. $('div.before').show();
  10. } else {
  11.             $('div.before').hide();
  12. }
  13. }
  14. </script>