Swapping content in a seperate div on hover

Posted by Fuego DeBassi on Stack Overflow See other posts from Stack Overflow or by Fuego DeBassi
Published on 2010-06-07T04:33:38Z Indexed on 2010/06/07 4:42 UTC
Read the original article Hit count: 287

Filed under:
|

I feel like this should work:

   $(".module .one").hover(function() {
     $("#viewport #one").addClass('red');
   });

Basically I am hiding all the .children of "#viewport on load, then when a seperate element is hovered, in this case .module .one I want to change something on the corresponding viewport ID #viewport #one.

Basic idea is a variable content window, where when a thumbnail or whatever I put in the modules swaps the content shown in the viewport. Something I am doing wrong?

Here is my full code:

<script type="text/javascript">
 $(document).ready(function() {
  $(".module .caption").hide();
  $("#viewport").children().hide();
  $(".module").hover(function() {
     $(this).find(".caption").slideDown().end().siblings('.module').addClass('under');
   },function() {
     $(this).find(".caption").slideUp().end().siblings('.module').removeClass('under');   
   });
   $(".module .one").hover(function() {
     $("#viewport #one").addClass('red');
   });
 });
</script>

The bigger hover function in the middle is for some fancy rollover effects that the modules will perform themselves, but for these purposes I just want to figure out why I can't add a Class to a separate element when another is hovered. Would love some help/advice!

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about show-hide