Found 695 Articles for JQuery

How to click anywhere on the page except one element using jQuery?

Rushi Javiya
Updated on 19-Jan-2023 09:09:09
We will learn to check if users have clicked anywhere on the page except one element using JavaScript and jQuery. While working with the modals, we require to close the modal when the user clicks the outside of the modal. So, we can achieve that using various methods of JavaScript or jQuery. Also, there are other use cases where we need to check whether users have clicked on a particular element. For example, when users click outside the dropdown menu, close the dropdown menu; Otherwise, select the option from the dropdown menu. Here, we have different approaches to check if ... Read More

How to send FormData objects with Ajax-requests in jQuery?

Shubham Vora
Updated on 08-Dec-2022 11:31:57
In this tutorial, we will learn How to send FormData objects with Ajax requests in jQuery. The FormData object stores value in the form of key-value pair. It mainly sends form data to the server with HTTP requests. If the form’s encoding type had been set to multipart/form-data, the submitted data would have been sent similarly via the submit() function. The FormData object contains multiple operations methods such as append, delete, set, etc. Syntax const formData = new FormData() formData.append('key', 'value') Users can follow the above syntax to create a FormData object. Asynchronous JavaScript And XML are referred to ... Read More

How to fix broken images automatically in jQuery?

Shubham Vora
Updated on 21-Nov-2022 09:20:06
In this tutorial, we will learn to fix broken images automatically in jQuery. Have you ever seen broken images while wondering on any website which shows only alternative text with the default icon of the broken image? Don’t you think it is a bad user experience? Obviously, it is. So, when you develop the application or website, you should write some JavaScript or jQuery code such that it can automatically replace broken images. Here, we will learn 2 to 3 different methods to fix broken images automatically using jQuery. Use the ‘onerror’ event inside the HTML ‘ ’ tag ... Read More

How to register a handler to be called when the Ajax request begins using jQuery?

Manav Sarkar
Updated on 20-Jul-2022 12:44:56
jQuery is a feature-rich JavaScript library. We can perform a lot of actions with the help of jQuery which would otherwise require writing large pieces of code. It makes DOM manipulation, event handling, animation, ajax, etc. very easy.In this tutorial, we will learn how to register a handler to be called when the first Ajax request begins using jQuery. Ajax requests are typically HTTP requests that are called by the browser for different tasks such as GET, POST, etc. So when the tasks are performed, we can register a handler using the ajaxStart() function of jQuery. This function is always ... Read More

How to register a handler to be called when all Ajax requests completed using jQuery?

Manav Sarkar
Updated on 20-Jul-2022 12:37:08
In this tutorial, we will learn how to register a handler to be called when all Ajax requests are completed using jQuery. Ajax requests are typically HTTP requests that are called by the browser for different tasks such as GET, POST, etc. So when the tasks are performed, we can register a handler using the ,ajaxStop() function of jQuery.SyntaxUse the following syntax to register a handler after an ajax request −$(document).ajaxStop(function () {    console.log('Registered handler.') })Explanation − Suppose we have a GET request on an API. When the API returns a result, jQuery checks if any requests are pending ... Read More

How to register a handler to be called when all Ajax requests completed using jQuery?

Manav Sarkar
Updated on 20-Jul-2022 12:32:25
In this tutorial, we will learn how to register a handler to be called when Ajax requests complete using jQuery. Ajax requests are typically HTTP requests that are called by the browser for different tasks such as GET, POST, etc. So when the tasks are performed, we can register a handler using the ajaxComplete() function of jQuery. This function is always triggered when the request is completed.SyntaxUse the following syntax to register a handler after every ajax request −$(document).ajaxComplete(function () {    console.log('Registered handler.') })Explanation − Suppose we have a GET request on an API. When the API returns a ... Read More

How to check the lock state of a callback list using jQuery?

Manav Sarkar
Updated on 20-Jul-2022 12:18:54
In this tutorial, we will learn how to check the lock-state of a callback list using jQuery. The lock is a callback list in jQuery in the current state. We can toggle the lock state so that additional changes cannot be made unless required.SyntaxThe callbacks list is locked and checked as follows −// Get callbacks list at current state var callbacks = $.Callbacks() // Lock the callbacks list callbacks.lock() // Check callbacks is locked or not console.log(callbacks.locked())AlgorithmFirst we receive the callbacks list at the current state using the Callbacks() function.Then we lock it using the lock() function and ... Read More

How to attach a function to be executed before an Ajax request is sent using jQuery?

Manav Sarkar
Updated on 20-Jul-2022 09:29:30
In this tutorial, we will learn How to attach a function to be executed before an Ajax request is sent using jQuery. Ajax requests are typically HTTP requests that are called by the browser for different tasks such as GET, POST, etc. So when the tasks are performed, we can register a handler using the ajaxSend() function of jQuery. This event is called by jQuery whenever an ajax request is to be made.SyntaxUse the following syntax to register a handler before an ajax request −$(document).ajaxSend(function () {    console.log('Triggered ajaxStart. Started Request') })We have an Ajax request. Before sending the ... Read More

How to add the previous set of elements on the stack to the current set in jQuery?

Manav Sarkar
Updated on 19-Jul-2022 13:00:27
jQuery is a feature-rich JavaScript library. We can perform a lot of actions with the help of jQuery which would otherwise require writing large pieces of code. It makes DOM manipulation, event handling, animation, ajax, etc. very easy.In this tutorial, we will learn to add the previous set of elements on the stack to the current set. jQuery maintains an internal stack of the changes that are performed to the matched stack. When the DOM traversal functions or methods are called, the new elements are pushed into the stack. So to use previous stack elements, the addBack() method is called.SyntaxWe ... Read More

How to Drag / Pan an Image in a Container div using jQuery?

AmitDiwan
Updated on 13-Mar-2021 12:40:10
With the help of events like mousedown, mouseup and mousemove, we can translate the image thereby creating a drag effect.The following example portrays how an image can be moved using jQuery.Example Live Demo #parent{    position: absolute;    margin: 20px;    width: 200px;    height: 200px;    border-radius: 25px;    background-color: khaki; } #mover {    position: relative;    margin: 10px; } let ele = {startPositionX:0, startPositionY:0}; let disp = {x:0, y:0}; $('#parent').on("mousedown", function(e){    let container = $(this);    ele.startPositionX=e.pageX-disp.x;    ele.startPositionY=e.pageY-disp.y;    $(document).on("mousemove", function(e){       disp.x=e.pageX-ele.startPositionX; ... Read More
Previous 1 ... 7 8 9 10 11 ... 70 Next
Advertisements