Usejquery

jQuery Effect deQueue() Method

If you need to remove a function from the queue, then you can call dequeue() jQuery method.

jQuery deQueue()

The dequeue() is a jQuery inbuilt method, which is used to remove the next function from the queue and then executes the function. You have to make sure that the dequeue() is called only after adding a function with queue, to allow the process to continue.

General Syntax of jQuery deQueue()

selector.deQueue(queueName);

In this jQuery deQueue() syntax, the parameter queueName is an optional argument that specifies the name of the queue. The default value is fx, the standard effects queue.

The most important aspects that deals with events via jQuery is blind() method. From the name itself, it is used to attach one or more events on a set of elements. It is a method specifies a function to run while the event occurs. This method will be used together with other events.

Syntax for bind() method

$(selector).bind(event,data,function,map)

The parameters of bind() methods are event, data, function and map. Here, event and data parameters are mandatory.

  • Event – specifies one or several events to attach to the elements. You can add many events separated by space.
  • Data – used to mention added data to pass along to the function. It is an optional parameter.
  • Function – It is a mandatory parameter, used to executes the function to run when the event occurs.
  • Map – specifies an event map that contains one or more events attached to the element.

To animate an element in jQuery, animate() method is used to perform a custom animation of a set of CSS properties. It is an inbuilt method used to change the state of an element with CSS style. Using this, you can change the element from one state to another with the style properties such as width, height, and opacity.

Syntax for animate() method

Let’s see the basic syntax of the animate() jQuery method, which is given below:

(selector).animate({styles},speed,easing,callback)

Styles defines one or more CSS properties value to animate and a required property.

Speed is an optional one, which is used to specify the speed of the animation effect.

Easing is also optional and used for animation function like swing or linear.

Callback parameter specifies which function to be called after the animation is completed.

Simple Example for animate()

Following program is a simple example to show how the animate () function is used.

How to use jQuery :empty Selector

The :empty selector in jQuery is used to select all elements that are empty, which have no child elements including text. In simple words, it is used to select empty elements. An empty element is an element without text or child elements.

:empty Selector Syntax

$(“:empty”)

jQuery not() Method with Example

In jQuery not() method returns elements, which do not match a particular condition. The elements that don’t match the condition are returns from the selection and those match will be removed.

It is used to remove one or more elements from set of selected elements. This not() method is simply opposite to filter() method.

Syntax of jQuery not() method

$(selector).not(criteria,function(index))

jQuery prepend() and prependTo() with Examples

In jQuery, both prepend() and prependTo() inbuild methods are  doing the same task, which add html elements or some content before the content of the selected elements. Then, you may think what is the difference between it. The major difference is the syntax. Let’s see the syntax for both functions:

Syntax

Syntax for prepend()

$(‘selector’).prepend(‘new text’);

This function has 2 parameters, new text is to specify the content to be inserted and the selector is to specify the elements to prepend the content.  

Syntax for prependTo()

$(‘new text’).prependTo(‘selector’);

jQuery clearQueue() Function with Example

Basically, we all know that the jQuery will make the code simple and easy to do more. Likewise, if you are having an unexecuted or unused animated item in a queue and wish to clear it, then clearQueue() jQuery method will do it.

Here, in this section we will show you how to remove unexecuted animation from jQuery using the function clearQueue().

Using the clearQueue() method, you can remove all items from the queue that have not yet been run. Moreover, once a function has started to run, it runs until it is completed.

Syntax

$(selector).clearQueue(queueName)

The parameter queuname is optional that specifies the name of the function.

Example Code for clearQueue()

$(“button”).click(function(){

    $(“div”).clearQueue();

});

(Visited 120 times, 4 visits today)