I
I
istasiik2014-10-04 12:11:03
JavaScript
istasiik, 2014-10-04 12:11:03

Why doesn't the second element in .queue work?

There is this script:

<script>
$(document).ready(function(){
$( "#anm-wrong" ).click(function() {
  $(".forms-block").queue(function() {
                     $(this).toggleClass( "animated shake" );
                    $(this).toggleClass( "animated shake" );
                    $(this).dequeue();
});
});
});
</script>


which does nothing at all. But if you remove the second toggleClass, then the first one already starts working. What am I doing wrong? With this, another script works completely:
<script>
$(document).ready(function(){
$( "#anm-wrong" ).click(function() {
  $(".placeHolder").queue(function() {
                     $(this).toggleClass( "required", 500 );
                    $(this).toggleClass( "required", 500 );
                    $(this).dequeue();
});
});
});
</script>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
asdz, 2014-10-04
@istasik

In the first example you add and immediately remove animated shake classes, in the second example you always add animated shake classes because pass 500 as the second argument, although the docs say that you should simply pass true / false: true - will add a class, false - will remove, i.e. you add twice. And bool from 500 is always true

A
Alexander Taratin, 2014-10-04
@Taraflex

I come home shorter, I press the switch 2 times in a row, but the light does not light up, and if you press it 1 time it starts to work. What am I doing wrong?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question