Articles on Trending Technologies

Technical articles with clear explanations and examples

How can I remove all child elements of a DOM node in JavaScript?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 14K+ Views

When building web applications, you often need to clear dynamic content like task lists, shopping carts, or search results. JavaScript provides several methods to remove all child elements from a DOM node efficiently. Here are the main approaches to remove all child elements: Using the removeChild() method with iteration Setting innerHTML to an empty string Using jQuery's empty() method Using the modern replaceChildren() method Using removeChild() Method with Iteration This method iterates through all child nodes and removes them one by one using removeChild(). It's reliable and works across all browsers. Syntax ...

Read More

How to determine if JavaScript object is an event?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 2K+ Views

In JavaScript, distinguishing between regular objects and event objects is important when handling user interactions and DOM events. An event object contains information about an event that occurred, such as mouse clicks or keyboard presses, while regular objects store data as properties and methods. JavaScript events are actions that happen in the browser, like clicking a button or loading a page. When these events occur, JavaScript creates event objects that contain details about what happened. Let's explore two reliable methods to check if an object is an event. Using the target Property Event objects have a target ...

Read More

How to delete a row from a table using jQuery?

Saleh Alshahrani
Saleh Alshahrani
Updated on 15-Mar-2026 4K+ Views

In this article, we will learn to delete a row from a table using jQuery. jQuery, a fast and lightweight JavaScript library, makes DOM manipulation simple. Deleting a row from a table dynamically is a common requirement in web development, especially when working with forms or data tables. Approach to Delete Rows The approach involves attaching a click event listener to a delete button within the row. When the button is clicked, the corresponding row is removed from the table using jQuery methods. Key jQuery Methods Used The $(document).on('click', 'button.deletebtn', function ...

Read More

How to add a new list element under a \'ul\' using jQuery?

Alshifa Hasnain
Alshifa Hasnain
Updated on 15-Mar-2026 4K+ Views

In this article, we will learn to add a new list element under a "ul" using jQuery. jQuery is a popular JavaScript library that simplifies HTML manipulation, event handling, and animations. One of its practical applications is dynamically adding elements to a webpage without requiring a full page reload. Why Use jQuery? DOM (Document Object Model) updating using basic JavaScript might become difficult and needs more than one line of code. jQuery has simplified it through easy selectors and functions. Employing jQuery helps us: Select elements efficiently Handle ...

Read More

What is the difference between jQuery and JavaScript?

Kiran Kumar Panigrahi
Kiran Kumar Panigrahi
Updated on 15-Mar-2026 2K+ Views

Both JavaScript and jQuery serve the same overarching objective of making webpages more interactive and dynamic. They give websites a sense of vibrancy. People may ask why there is a need for two distinct concepts if they serve the same function. Read through this article to find out how jQuery differs from JavaScript. What is JavaScript? JavaScript is a lightweight programming language that is used most often as a component of webpages. Its webpage implementations enable client-side script to interact with the user and create dynamic sites. It is a programming language that is interpreted and can handle ...

Read More

How to handle bind an event using JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 11K+ Views

In this tutorial, we will learn how to bind events using JavaScript. Events are actions or occurrences triggered by the browser or users. There are various types of events that represent different activities. For example, if a user clicks on a button, it triggers a "click" event. Similarly, when a webpage finishes loading, it triggers a "load" event. An Event Listener is a program that continuously listens for events to occur. Event Handlers are functions that execute when an event occurs. JavaScript binds events to their respective event handlers using the addEventListener method. Binding Events with addEventListener ...

Read More

JavaScript variables declare outside or inside loop?

Abdul Rawoof
Abdul Rawoof
Updated on 15-Mar-2026 5K+ Views

In JavaScript, variables can be declared either inside or outside loops without performance differences. However, the choice affects variable scope and code readability. Variable Scope: var vs let With var, variables are function-scoped regardless of where declared. With let, variables are block-scoped, meaning they're only accessible within their block. Example: Variable Declared Outside Loop When declared outside, variables have broader scope and can be accessed throughout the function: function myFunction1() { var i; // Function scope - can be used throughout the function ...

Read More

Is it possible to change values of the array when doing foreach() in javascript?

Abdul Rawoof
Abdul Rawoof
Updated on 15-Mar-2026 6K+ Views

Yes, it is possible to change array values during forEach() iteration in JavaScript. Unlike some programming languages where modifying arrays during iteration is restricted, JavaScript's forEach() allows you to modify the original array by using the array parameter or accessing the array directly by index. The forEach Method The forEach() method executes a provided function once for each array element. It passes three parameters to the callback function: the current element value, the element's index, and the array itself. You can use the array parameter to modify elements during iteration. Syntax array.forEach(function(value, index, array) { ...

Read More

What's the difference between window.location and document.location?

Abdul Rawoof
Abdul Rawoof
Updated on 15-Mar-2026 3K+ Views

In JavaScript, both window.location and document.location provide access to the current page's URL information, but they have subtle differences in browser compatibility and usage patterns. The window.location Property The window.location property is a reference to a Location object that represents the current URL of the document being displayed in that window. Since the window object is at the top of the scope chain, you can access location properties without the window prefix (e.g., location.href instead of window.location.href). Example: Getting Current URL JavaScript Get Current URL ...

Read More

Get div height with vanilla JavaScript

Abdul Rawoof
Abdul Rawoof
Updated on 15-Mar-2026 13K+ Views

The HTML element is a container used to group and style other HTML elements. Getting the height of a div element is a common task in JavaScript, and there are several properties available to achieve this, each measuring different aspects of the element's dimensions. Using offsetHeight The offsetHeight property returns the total height of an element including content, padding, border, and scrollbar (if present). Syntax element.offsetHeight The offsetHeight includes: offsetHeight = content height + padding + border + scrollbar height ...

Read More
Showing 19241–19250 of 61,299 articles
Advertisements