: jQuery. , :
jQuery
- ajax. SO , , , -
, AJAX. setTimeout , AJAX, ...
$('#elementId').click(function (e) {
var $element = $(e.currenttarget);
$element.queue('myqueue', function () {
var $el = $(this);
$el.dequeue();
});
});
:
- click
- 'myqueue'
- , , - , jQuery 'this'.
, dequeue , window.setTimeout(500, function () { $this.dequeue(); });, 500 ...
jQuery
This function is similar to providing a callback function using animation, but does not require that the callback be indicated while the animation is running.
$( "#foo" ).slideUp(); $( "#foo" ).queue(function() {
alert( "Animation complete." );
$( this ).dequeue();
});
This is equivalent to:
$( "#foo" ).slideUp(function() {
alert( "Animation complete."
); });
Note that when adding a function with .queue (), we must make sure that .dequeue () is ultimately called so that the next function in the line is executed.
Update. The answer has been modified to include a working script and some explanation.
source
share