I am trying to animate a UL on a button click. It works if i simply change the margin-left but fails when I try to animate. Here is the code:
$(".btn_right").click(function(){
var curLeft=$("ul#questions").css('margin-left').replace("px", ""); //Current left margin
var newLeft=curLeft-245; //Set to required
alert(newLeft); //Confirm New margin left
//$("ul#questions").css("margin-left",newLeft+"px"); - THIS WORKS
$("#ulquestions").animate({marginLeft: "23px"}, 500); //THIS DOESNT
return false;
});
I think I am just overlooking a simple mistake. Any ideas guys? The js console is not giving me any error.
Thanks.
Your selectors are different
$("ul#questions") vs$("#ulquestions")Try this