Tag Archives: learning jquery online

jQuery removeClass Method


jQuery removeClass Method : is used to remove the classes from the selected elements.


Syntax : jQuery removeClass Method

$(selector).removeClass(classname,function(index,currentClassName));

index: (Interger) Index of the current element in the current set.
currentClassName(String)Current Class name in the matching set.

jQuery removeClass() Method Example 1


Try it »

jQuery after Method


jQuery after method : is used to add new html element(content) after the selected element ie. after outside of the element.


Syntax

$(selector).after('some......content');

jQuery after Method Example

jQuery after() Method with syntax


Try it »

jQuery text method


jQuery text method : is used to read or write the text in the html.


Syntax of jQuery text() method

Get Text

$(selector).text();

Note : It does not accepts any argument.

jQuery text Method with syntax

jQuery text() Method – Example 1 – Get The Text


Try it »

Set Text

$(selector).text(text);

text: String,Number or Boolean to be set as content.

jQuery text Method with syntax

jQuery text() Method – Example 2 – Set The Text


Try it »

jQuery slice method


jQuery slice method – jQuery “slice() Method ” is used to select elements between the two indices. $(selector).slice(start,end) requires the start and end parameter along with the selector.

We are going to explain this method with the example and demo.


Syntax : jQuery slice() method

Syntax of slice method is –

$(selector).slice(start,end);

start : It is integer which indicates the position of the elements which starts with 0 from where selection of elements will begin. The negative no means start from the end of the element set.
end : It is integer which indicates the position of the elements which starts with 0 from where stop of elements will be selected. The negative no means start from the end of the element set.

jQuery slice Method Example

Here is an example of slice method click on try it button to see the output-

jQuery slice() Method – Example


Try it »

If you run the above example it will produce the following output-

jQuery slice Method Example

jQuery prevUntil Method


jQuery prevUntil Method : jQuery “prevUntil() Method ” is used to get all previous siblings between selector and selector-element ie. stop point where to stop matching previous siblings elements. Here is more info about how to use jQuery prevUntil Method efficiently. We will explain the prevUntill() method with simple example.


Syntax : jQuery prevUntil Method

Here is syntax of prevUntill method And Example-

$(selector).prevUntil(selector-element,filter);

selector-element It is stop point where to stop matching previous elements
filter : It is optional, A selector expression used to match(previous siblings) the elements against.

jQuery parentsUntil Method Example

jQuery prevUntil() Method – Example


Try it »

In the above example the elements from span tag up to the class .level-two will be added bordered.

The above code will produce the following output –

Note : Below is image output only for demo click above “Try It” Button.

jQuery parentsUntil Method

jQuery prevAll Method


jQuery “prevAll() Method ” is used to get all previous elements of the selected element.


Syntax : jQuery prevAll() method

$(selector).prevAll(filter);

filter : It is optional, A selector expression used to match the elements against.

jQuery prevAll Method demo Example

jQuery prevAll() Method – Example 1


Try it »

jQuery prevAll Method demo Example

jQuery prevAll() Method – Example 2


Try it »

jQuery prev method


jQuery “prev() Method ” is used to get previous elements of the selected element.


Syntax : jQuery prev() method

$(selector).prev(filter);

filter : It is optional, A selector expression used to match the elements against.

jQuery prev Method Example with syntax

jQuery prev() Method – Example 1


Try it »

jQuery prev Method Example with syntax

jQuery prev() Method – Example 2


Try it »

jQuery parent Method


jQuery parent Method – jQuery “parent()” is used to get parent of the selected element.

This method becomes useful when you want to get parent of the element in DOM. We are going to explain this method will full example and demo.


jQuery parent() method

Here is syntax for parentsUntil Method –

$(selector).parent(filter);

filter : It is optional, A selector expression used to match(parent) the elements against.

jQuery parent() Method Example with Syntax

Here is an example with demo try it to test the functionality of the parent method-

jQuery parent Method – Example 1


Try it »

jQuery parent() Method Example with Syntax

jQuery parent Method – Example 2


Try it »

The above example will produce the following output as below –

jQuery parent Method Example And Demo

jQuery not Method


jQuery “not()” is used to remove the element from set of the matched elements. We have explained not method in jQuery with example and demo. Lets check out syntax of jQuery not Method and try it with our live editor.


Syntax : jQuery not() method

Here is syntax for jQuery not Method –

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

Criteria : Is selector expression, jQuery object or element which is removed from matched element.
function : Runs for each element and returns true if the element is removed from the set.

jQuery not Method Example with Editor

Here is an example with demo try it to test the functionality of the not method-

jQuery not() Method – Example


Try it »

The above example will produce the following output as below –

jQuery not Method