How can I show image rollover with a mouse event in JavaScript?

Shubham Vora
Updated on 15-Mar-2026 23:18:59

10K+ Views

This tutorial will teach us to show image rollover with a mouse event in JavaScript. The meaning of the image rollover is to either change the image style or the whole image when the user rollovers the mouse on the image. To build an attractive user interface, developers often add image rollover features to the website and applications. Here, we will see to apply image rollover differently. Change the Style of the Image on Mouse Rollover In this method, to create the image rollover, we will use the onmouseover and onmouseout event of JavaScript. When users take ... Read More

Mouse event not being triggered on HTML5 canvas? How to solve it?

Arjun Thakur
Updated on 15-Mar-2026 23:18:59

631 Views

When HTML5 canvas mouse events fail to trigger, it's often due to CSS transforms or missing event listeners. Here are proven solutions to fix this issue. Problem: CSS Transform Interference CSS 3D transforms can interfere with mouse event coordinates on canvas elements. The solution is to force hardware acceleration: /* Add this CSS to your canvas */ canvas { -webkit-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0); } Solution 1: Adding Mouse Event Listeners Ensure you properly attach event listeners to the canvas element: ... Read More

Which one is faster between JavaScript and an ASP script?

Lokesh Yadav
Updated on 15-Mar-2026 23:18:59

1K+ Views

In this article, we are going to discuss the performance differences between JavaScript and ASP script in web development contexts. JavaScript is a lightweight, interpreted language primarily used for client-side scripting. It executes directly in the browser, making the code visible to users. JavaScript files use the .js extension. Active Server Pages Script (ASP) is a server-side scripting technology used to create dynamic web pages. ASP files have the .asp extension and execute on the web server before sending results to the client. Architecture and Execution Context In a three-tier architecture (Presentation, Application, and Data layers), ... Read More

Can we have a return statement in a JavaScript switch statement?

AmitDiwan
Updated on 15-Mar-2026 23:18:59

21K+ Views

Yes, you can use return statements in a JavaScript switch statement, but only when the switch is inside a function. The return statement will immediately exit the function with the specified value, making break statements unnecessary. How Return Statements Work in Switch When a return statement is executed in a switch case, it immediately exits the function and returns the value. This eliminates the need for break statements since the function execution stops. Example: Day Name Function Return ... Read More

Remove duplicates from a array of objects JavaScript

AmitDiwan
Updated on 15-Mar-2026 23:18:59

741 Views

Removing duplicates from an array of objects is a common task in JavaScript. We need to identify objects with the same properties and values, keeping only unique objects in the result. Using JSON.stringify() with Map The most straightforward approach uses JSON.stringify() to convert objects to strings for comparison: const arr = [ { "timestamp": 564328370007, "message": "It will rain today" }, { ... Read More

How to use JavaScript map() method to access nested objects?

AmitDiwan
Updated on 15-Mar-2026 23:18:59

5K+ Views

The map() method can be used to iterate through arrays of nested objects and safely access their properties using conditional checks. Understanding Nested Objects When working with arrays containing objects that have different structures, some objects may have nested properties while others don't. Here's our sample data: var details = [ { id: "101", firstName: "John", lastName: "Smith", age: 25, ... Read More

What is the difference between new operator and object() constructor in JavaScript?

Rishi Rathor
Updated on 15-Mar-2026 23:18:59

1K+ Views

Both the new operator and Object() constructor are used to create objects in JavaScript, but they serve different purposes and contexts. The new Operator The new operator is used to create an instance of an object. It works with constructor functions to instantiate objects and automatically handles the object creation process. var department = new Object(); var books = new Array("C++", "Perl", "Java"); var day = new Date("December 1, 2017"); document.write("Department: " + typeof department + ""); document.write("Books: " + books + ""); document.write("Date: " + day + ""); ... Read More

How to set the starting position of a background image in JavaScript DOM?

Sharon Christine
Updated on 15-Mar-2026 23:18:59

586 Views

To set the starting position of a background image in JavaScript, use the backgroundPosition property. This property allows you to specify where the background image should be positioned within its container. Syntax element.style.backgroundPosition = "value"; Position Values The backgroundPosition property accepts various values: Keywords: top, bottom, left, right, center Percentages: 50% 25% (horizontal vertical) Pixels: 10px 20px (horizontal vertical) Mixed: left 50px, center top Example: Setting Background Position body { ... Read More

Upload from local drive to local filesystem in HTML with Filesystem API

vanithasree
Updated on 15-Mar-2026 23:18:59

304 Views

To upload files from your local drive to the local filesystem in the browser, HTML5 provides several powerful APIs that work together. This approach uses the webkitdirectory attribute, Filesystem API, and File API to create a complete file handling solution. Required APIs Three main APIs enable this functionality: webkitdirectory attribute - Allows users to select entire directories through a file dialog Filesystem API - Creates a sandboxed filesystem for storing files on the client's machine File API - Enables reading and processing selected files ... Read More

isFinite() function in JavaScript

karthikeya Boyini
Updated on 15-Mar-2026 23:18:59

114 Views

The isFinite() function accepts a value and determines whether the given value is a finite number or not. If so, this method returns true, else it returns false. You can also invoke this method using the Number object as Number.isFinite(). Syntax isFinite(value) Number.isFinite(value) Parameters value: The value to be tested for finiteness. Return Value Returns true if the value is a finite number, false otherwise. Example: Basic Usage JavaScript Example ... Read More

Advertisements