Categories
jQuery

$.stop() vs. $.finish() in jQuery animations

jQuery stop and finish methods are used to end of all of the queued animations. jQuery stop() method stops the currently running animation on the matched elements but jQuery finish() stops the currently running animation, removes all the queued animations and complete all the animations for the matched elements. Let’s see what jQuery stop and finish […]

Categories
jQuery

Difference between toArray and makeArray in jquery

jQuery toArray and makeArray both are the useful function to build with the transforming. The jQuery toArray() transforms jQuery element set to javaScript Array, jQuery.makeArray() transforms any array like object to JavaScript Array. Let’s see the difference between toArray and makeArray in jQuery. The jQuery toArray() method returns the elements contained in the jQuery selector […]

Categories
jQuery

jQuery toggleClass() Method

The jQuery toggleClass() Method toggles between adding and removing one or more class names from each element in the set of matched elements. Example of jQuery toggleClass: Suppose, we have below HTML: <div class=”myclass”>Your text here.</div> When you apply $( “.myclass” ).toggleClass( “newClass” ), we get the following: <div class=”myclass newClass”>Your text here.</div> Again, if […]

Categories
jQuery

jQuery trigger() method

jQuery trigger() method triggers the default behavior of a specified event for a selected elements. Although the .trigger() simulates an event activation by completing with a synthesized event object, that does not perfectly replicate a naturally-occurring event. Suppose you are trying to trigger an event on the anchor. So in this case you can call […]

Categories
jQuery

jQuery unwrap() – Remove wrapping div

The unwrap() method remove the parents of the selected elements from the DOM and leave the matched elements in their place. .unwrap() method does not accept any arguments. Example of jQuery unwrap: You have the following HTML: <div class=”main”> <div class=”wrap”><div class=”sub”>John Doe</div></div> <div class=”wrap”><div class=”sub”>Jane Doe</div></div> </div> Using .unwrap() method you can remove wrapping […]

Categories
jQuery

Check if an element is Visible/Hidden with jQuery

In jQuery, the :visible selector selects each elements which is currently visible or check whether element is visible or not. Basically, elements are considered visible when they consume space in a document. So, visible elements have a width or height greater than zero. Elements with “visibility: hidden” or “opacity: 0” are considered as visible, because […]

Categories
jQuery

jQuery – Get hidden element width

In jQuery, when an element is not visible, the width() returns 0. But involving some CSS properties we can make jQuery think that the element is visible. For example, you have the following HTML: <div class=”main”> <div class=”sub” style=”display:none;”>John Doe</div> <div class=”sub” style=”display:none;”>Jane Doe</div> </div> If you want to get the hidden element width of […]

Categories
jQuery

jQuery wrap() Method

jQuery wrap Method wraps specified HTML element(s) around each element in the set of matched elements. This wrapping process is very useful for injecting any additional structure into a document, without destroying the original semantic qualities of the document. Possible values are: HTML elements jQuery objects DOM elements This is the simple syntax to use […]

Categories
jQuery

jQuery wrapAll – wrap all elements

jQuery wrapAll wraps specified HTML element(s) in the set of matched elements. This takes any string or object for passing into $() function to specify the HTML DOM structure. Around all the elements the structure will be wrapped as a single group. Example of jQuery wrapAll: Suppose you have following HTML: <div class=”main”> <div class=”sub”>John […]

Categories
jQuery

jQuery wrapInner – wrap element around the content

jQuery wrapInner wraps specified HTML element(s) around the content of each element in a set of matched elements. It may be nested structure but it should contain only one inmost element. Possible values of jQuery wrapInner: – HTML elements – jQuery objects – DOM elements Suppose you have following HTML: <div class=”main”> <div class=”sub”>John Doe</div> […]