I am trying to make a button that, when I click the button, set position to left=0px;
of a element and when further clicked set position to right=0px;
and continue toggling when clicking.
But it failed because it write ass inline CSS. without toggleClaas and adding CSS property How can I do this with JQuery?
My Code:
$(".something").click(function(){
$(".name").animate({left: "0px"},1000);
//when again clicked do this event
//$(".name").animate({right: "0px"},1000);
});
Instead of
$(".something").click(function(){
$(".name").toggleClass("active");
});
CSS:
.name{left: 0px;}
.active{right: 0px;}
2
Answers
Try this
You can do it by initializing the button by
right:0px
then whenever you click the position will change as follows :