Как при втором нажатии на кнопку вернуть квадрат обратно? Код ниже.
By default, all HTML elements have a static position, and cannot be moved. To manipulate the position, remember to first set the CSS position property of the element to relative, fixed, or absolute!
Ответ
используйте toggleclass и transition для плавности:
$("button").click(function(){
$("div").toggleClass('move_right');
});
div {
left: 0px;
transition: all .5s;
background:#98bf21;
height:100px;
width:100px;
position:absolute;
}
.move_right {
left: 250px;
}
By default, all HTML elements have a static position, and cannot be moved. To manipulate the position, remember to first set the CSS position property of the element to relative, fixed, or absolute!
Комментариев нет:
Отправить комментарий