Jquery - slideleft, code not working?
Question
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>
Solution
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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow