eq(), first() and last() JQuery functions

In this post of JQuery, I will explain the three functions eq(), first(), and last() functions with a example. Below is the complete code for reference 1 <html> 2 <head> 3 <a href=”https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js”>https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js</a&gt; 4 </head> 5 <body> 6 7 function selectElement() { 8 var $elements = $(‘a’); 9 10 var $indexedElement = $elements.eq(0); 11 alert($indexedElement.length);…… Continue reading eq(), first() and last() JQuery functions

Selecting elements by their attributes

In this post of JQuery, I will show how to select elements using their attributes. Below is the complete html code that will be used as an example 1 <html> 2 <head> 3 <a href=”https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js”>https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js</a&gt; 4 </head> 5 <body> 6 7 function selectElement() { 8 var $element = $(‘a[href]’); 9 $(‘#input1’).val($element.length); 10 11 $element =…… Continue reading Selecting elements by their attributes

Selecting elements that are descendants of another element

In this post of JQuery, I will show how to select elements that are descendants of another element. Below is the complete html code that will be used as an example 1 <html> 2 <head> 3 https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js 4 </head> 5 <body> 6 7 function selectDescendantElement() { 8 var $element = $(‘div li’); 9 alert($element.length); 10…… Continue reading Selecting elements that are descendants of another element

Selecting elements that are direct children of another element

In this post of JQuery, I will show how to select elements that are direct childrens of another element. Below is the complete html code that will be used as an example 1 <html> 2 <head> 3 https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js 4 </head> 5 <body> 6 7 function selectElementByHierarchy1() { 8 var $element = $(‘#Items1 > li’); 9…… Continue reading Selecting elements that are direct children of another element