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?
- <div class="before"></div>
- <div id="slideshow">
- <img class="before" src="image-1.jpg">
- <img src="image-2.jpg">
- </div>
- <script type="text/javascript" charset="utf-8">
- $(document).ready(function(){
- if ($('#slideshow img').hasClass('before') {
- $('div.before').show();
- } else {
- $('div.before').hide();
- }
- }
- </script>