How to make smooth animation, when I use Jquery toggleClass method? I used css transitions, but there is a delay, but there is no smoothness.
.paragraph {
height: 35px;
overflow: hidden;
transition: .5s;
}
How to make smooth animation, when I use Jquery toggleClass method? I used css transitions, but there is a delay, but there is no smoothness.
.paragraph {
height: 35px;
overflow: hidden;
transition: .5s;
}
You can use jQuery's toggleClass to add transition effects: JSFiddle
$('.i-btn').click(function() {
$(this).prev('.paragraph').toggleClass("paragraph_all", 1000);
if ($(this).prev('.paragraph').hasClass('paragraph_all')) {
$(this).text('Show');
} else {
$(this).text('Hide');
}
});
Make sure you also add the jQuery UI link: https://code.jquery.com/ui/1.12.1/jquery-ui.min.js
And here is the documentation & demo.