- jQuery - Home
- jQuery - Roadmap
- jQuery - Overview
- jQuery - Basics
- jQuery - Syntax
- jQuery - Selectors
- jQuery - Events
- jQuery - Attributes
- jQuery - AJAX
- jQuery CSS Manipulation
- jQuery - CSS Classes
- jQuery - Dimensions
- jQuery - CSS Properties
- jQuery Traversing
- jQuery - Traversing
- jQuery - Traversing Ancestors
- jQuery - Traversing Descendants
- jQuery References
- jQuery - Selectors
- jQuery - Events
- jQuery - Effects
- jQuery - HTML/CSS
- jQuery - Traversing
- jQuery - Miscellaneous
- jQuery - Properties
- jQuery - Utilities
- jQuery Plugins
- jQuery - Plugins
- jQuery - PagePiling.js
- jQuery - Flickerplate.js
- jQuery - Multiscroll.js
- jQuery - Slidebar.js
- jQuery - Rowgrid.js
- jQuery - Alertify.js
- jQuery - Progressbar.js
- jQuery - Slideshow.js
- jQuery - Drawsvg.js
- jQuery - Tagsort.js
- jQuery - LogosDistort.js
- jQuery - Filer.js
- jQuery - Whatsnearby.js
- jQuery - Checkout.js
- jQuery - Blockrain.js
- jQuery - Producttour.js
- jQuery - Megadropdown.js
- jQuery - Weather.js
jQuery :animated Selector
The :animated selector in jQuery is used to select all elements that are currently being animated with jQuery's animation effects.
Syntax
Following is the syntax of jQuery :animated selector −
$(":animated")
Parameters
The :animated will select the elements that are currently animated.
Example
In the following example, we are using the :animated selector to apply styles to elements that are currently being animated −
<!DOCTYPE html>
<html>
<head>
<title>jQuery :animated Selector Example</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
function animateDiv(){
$("div:eq(0)").animate({height: "toggle"}, "slow");
$("div:eq(0)").animate({height: "toggle"}, "slow", animateDiv);
}
animateDiv();
$(".btn2").click(function(){
$(":animated").css("border", "5px solid black");
});
});
</script>
<style>
div {
width: 100%;
padding: 20px;
margin-bottom: 10px;
color: white;
text-align: center;
font-size: 1.2em;
}
</style>
</head>
<body>
<button class="btn2">Add border to the animated element</button>
<div style="background:purple;">Box 1</div>
<div style="background:orange;">Box 2</div>
<div style="background:teal;">Box 3</div>
</body>
</html>
When execute and click on the button, the :animate will select the animating element and add a black border around it.
jquery_ref_selectors.htm
Advertisements