Reputation: 1930
I have a div as follows.
html:
<div id="leftdock"></div>
css:
#leftdock
{
position: absolute;
float:left;
height: 400px;
width: 200px;
margin-left: -50px;
border-radius: 0px 10px 10px 0px;
background-color: #BADA7F;
top: 30%;
}
following javascripts using jQuery:
$(document).ready(function () {
$('#leftdock').mouseenter(function () {
$(this).animate({
margin-left: "-25px"
}, 500);
});
$('#leftdock').mouseleave(function () {
$(this).animate({
margin-left: "-25px"
}, 500);
});
});
But with this the animation does not work. My div margin-left is not changing with mouseenter/leave even.
Upvotes: 0
Views: 119
Reputation: 23208
This may solve your problem
$(document).ready(function () {
$('#leftdock').mouseenter(function () {
$(this).animate({
'margin-left': -25
}, 500);
});
$('#leftdock').mouseleave(function () {
$(this).animate({
'margin-left': -25
}, 500);
});
});
Upvotes: 2