I am animating different div
s (jQuery and jQuery UI), so I have created classes like ,slidein
, fadein
, etc., and I can apply them to whatever I need to animate. In my Javascript file, a .each()
loop is run to find every element with a class of fadein
or sidein
What I want to do is be able to choose how long the animation takes, by adding a class of fadein-x
, where x
is the number of milliseconds it took. For instance:
.fadein-500
- Element will take 500
milliseconds to fade in
.slidein-1000
- Element will take 1000
milliseconds to slide in
Using a .each()
function I can loop through the elements with a specific class, but could I loop through all the elements with a class that starts with a specific string, like a wildcard? Maybe something like this (where *
is the wildcard):
$('.fadein-*').each(...)
The above would select all elements with the fadein-
class, and then I could slice the class to get the time, and apply the animation.
So, in conclusion, this is what I want:
Be able to animate elements with a customizable time, without having to change a Javascript file
If there is another way to do what I am trying to do, please tell me! Thanks
Note: The reason I need this is because I am creating a Wordpress theme, and I will be using PHP to echo a time the user types in. Obviously I don't want to create 3000 different classes for every time in milliseconds possible
Also, this question is not the same, the OP was asking about something different