jQuery Articles

Page 18 of 42

How to add the previous element to current jQuery selection?

David Meador
David Meador
Updated on 13-Mar-2026 666 Views

To add the previous element to current jQuery selection, use the insertBefore() method. This method inserts selected elements before the specified target element in the DOM. Syntax The basic syntax of the insertBefore() method is − $(content).insertBefore(target) Where content is the element to be inserted and target is the element before which the content will be placed. Example You can try to run the following code to learn how to work with insertBefore() method − ...

Read More

How to filter object array based on attributes in jQuery?

David Meador
David Meador
Updated on 13-Mar-2026 2K+ Views

To filter object array based on attributes in jQuery, use the map() method with JSON. The $.map() function creates a new array with the results of calling a provided function on every element in the calling array. Example You can try to run the following code to learn how to filter object array based on attributes in jQuery. This example filters department data based on employee count and shares criteria − ...

Read More

What is the difference between Grep and Filter in jQuery?

David Meador
David Meador
Updated on 13-Mar-2026 1K+ Views

The grep() method finds elements in an array based on a filter function, while the filter() method returns DOM elements from a jQuery selection that match specific criteria. jQuery grep() Function The jQuery grep() function is used to filter elements from an array. It searches through array elements and returns a new array containing only elements that pass the test function. Example The following example demonstrates how to use grep() to filter array elements − jQuery grep() function div { ...

Read More

What is the difference between .closest() and .parents() methods in jQuery?

Amit D
Amit D
Updated on 13-Mar-2026 1K+ Views

The jQuery closest() and parents() methods are used to traverse up the DOM tree to find ancestor elements. While both methods search for ancestors, they differ in their search behavior and return values. Let's explore the key differences between these two methods. jQuery closest() method The closest() method begins with the current element itself and travels up the DOM tree to find the first ancestor that matches the specified selector. This method returns a jQuery object containing zero or one element. Key characteristics of closest() The closest() method − Starts from ...

Read More

What is the difference between jQuery add() & jQuery append() methods in jQuery?

Amit D
Amit D
Updated on 13-Mar-2026 430 Views

The jQuery add() and jQuery append() methods serve different purposes in jQuery. The add() method is used to combine elements into a single jQuery selection, while the append() method is used to insert content inside existing elements. jQuery add() Method The add() method adds elements to an existing group of elements, creating a combined selection. This allows you to apply the same operation to multiple different elements at once. Example You can try to run the following code to ...

Read More

How to get substring of a string in jQuery?

Amit D
Amit D
Updated on 13-Mar-2026 6K+ Views

To get substring of a string in jQuery, use the substring() method. It has the following two parameters: from − The from parameter specifies the index where to start the substring. to − The to parameter is optional. It specifies the index where to stop the extraction. When nothing is mentioned, it extracts the remaining string from the start index to the end. Syntax The syntax for the substring() method is − string.substring(from, to) Example You can try to run the following code to learn how ...

Read More

Building a mobile app using OpenUI5 and Cordova using framework like jQuery.sap.storage

Vrundesha Joshi
Vrundesha Joshi
Updated on 13-Mar-2026 359 Views

You are thinking correctly for your requirement. What you can do is, use the read method for each entityset to read the oData. In the success callback for this method, you can parse the result objects into a corresponding JSON model. Now, you can have working logic as per which − When you are online, use the additional layer to fill the JSON model from the oData that has been read When offline, you can read from local storage Implementation Approach The jQuery.sap.storage API provides local ...

Read More

Including third party libraries in SAPUI5 Project

Ali
Ali
Updated on 13-Mar-2026 519 Views

Including third party libraries in your SAPUI5 project allows you to leverage external functionality and extend your application capabilities. SAPUI5 provides several methods to incorporate these libraries safely and efficiently. Using jQuery.sap.require Method For libraries that are already included with SAPUI5, you can use the jQuery.sap.require method to load them. Here's how you would include jQuery UI components − jQuery.sap.require("sap.ui.thirdparty.jqueryui.jquery-ui-core"); This method ensures that the library is loaded properly within the SAPUI5 framework and maintains compatibility with the application lifecycle. Security Considerations When working with third party libraries, security is a crucial ...

Read More

How to change first and last elements of a list using jQuery?

Ricky Barnes
Ricky Barnes
Updated on 13-Mar-2026 834 Views

To change the first and last elements of a list, you can use jQuery's eq() method along with first() and last() methods. The eq() method allows you to select elements by their index position, where the first element has an index of 0. Methods for Selecting First and Last Elements jQuery provides several methods to target the first and last elements − :first or first() − Selects the first element :last or last() − Selects the last element ...

Read More

How to access element with nth index in jQuery?

Ricky Barnes
Ricky Barnes
Updated on 13-Mar-2026 1K+ Views

To access element with nth index from an HTML page, use the jQuery eq() method. It is used to access the index of an element in jQuery. The eq() method refers to the position of the element. The eq() method accepts a zero-based index parameter, meaning the first element is at index 0, the second element is at index 1, and so on. This method returns a jQuery object containing only the element at the specified index position. Syntax The ...

Read More
Showing 171–180 of 413 articles
« Prev 1 16 17 18 19 20 42 Next »
Advertisements