使用Animate.css为网页元素添加点击动画效果是一种非常流行的技术,可以大大提高网站的交互性和用户体验。以下是使用Animate.css为元素添加点击动画的代码示例:
点击我添加动画效果
function addAnimation() {
// 使用class添加动画效果
document.querySelector('.my-element').classList.add('animated', 'bounce');
// 一段时间后移除class,以便下一次添加动画效果
setTimeout(() => {
document.querySelector('.my-element').classList.remove('animated', 'bounce');
}, 1000);
}
上面的代码以添加"bounce"动画效果为例,您可以根据需要更改"bounce"为其他Animate.css提供的动画效果。