I have a problem. I just started learning jQuery, my first experience with javascript at all. And I want to make an element animate on click, and I did make that work:
HTML:
<h1>Testing</h1>
I'm using Animate.css to make some animations happen on click. Here's my jQuery:
$('h1').click(function (e) {
$('h1').addClass('animated bounce');
});
What I want to achieve is that when I click 2nd time, the animation happens again, in fact, I want to remove the animated bounce class and add it again, that way the animation will happen again.
<head>
<link rel="stylesheet" target='_blank' href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
</head>
<body>
<h1>Testing</h1>
<script>
$('h1').click(function (e) {
$('h1').addClass('animated bounce');
});
</script>
</body>
You need to remove the CSS class once the animation is over.
$('h1').click(function() {
$(this).addClass('animated bounce').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
$(this).removeClass();
});
});
<link rel="stylesheet" target='_blank' href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<h1>Testing</h1>
const map = {} for (let i=0;i<10**5;i++) { map[i] = true } let ans = 0 for (let i in map) { for (let j in map) { ans += i+j } } console.log(ans) The above code when run ...
const map = {} for (let i=0;i<10**5;i++) { map[i] = true } let ans = 0 for (let i in map) { for (let j in map) { ans += i+j } } console.log(ans) The above code when run ...
I'm using RSpec + capybara, and the capybara-webkit as driver. I have to check if a JS box exists in the page after clicking on a button, but with no results. If I use selenium as a driver, the test ...
I'm using RSpec + capybara, and the capybara-webkit as driver. I have to check if a JS box exists in the page after clicking on a button, but with no results. If I use selenium as a driver, the test ...
I have a div in which I have a button and a textarea. What is the easiest way to get my hands on a child from a given div by its id? <html> <head> <link rel="stylesheet" ...
I have a div in which I have a button and a textarea. What is the easiest way to get my hands on a child from a given div by its id? <html> <head> <link rel="stylesheet" ...
I'm using Template.uploadFile.events({ 'change .set-file': function ( event, template ) { var file = event.currentTarget.files[0]; [...] } }); when uploading a file. I want to read ...
I'm using Template.uploadFile.events({ 'change .set-file': function ( event, template ) { var file = event.currentTarget.files[0]; [...] } }); when uploading a file. I want to read ...