tags:

views:

284

answers:

1

Title is descriptive, what is wrong with this code and why?

<script type="text/javascript">

$(document).ready(function() {
  $('#slideleft').mouseenter(function() {
    var $lefty = $(this).next();
      $lefty.animate({ 
        left: "-2000px"
             }, 500 );
  });
});
</script>

HTML

<div id="slideleft" class="slide"> 

  <div class="inner">Animate this element's left style property</div> 
</div>
+1  A: 

The $(this).next() should be grabbing the next sibling of div#slideleft but it appears you actually want div.inner to be sliding right? If you change $(this).next() to $(this).children('.inner') it should work.

Darrell Brogdon
oh I see it grabs siblings, not children. Didn't know that...
Jared