Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Javascript Articles
Page 184 of 534
How to Create a Parallax Effect using HTML, CSS, and JavaScript?
In this article, we are going to learn about parallax effects and how to create them using HTML, CSS, and JavaScript. We will be using the mouse-move event to show the parallax effect. During the parallax effect, two different images move in parallel to each other. Both the images will be working parallel and making the same transitions. The only difference will be they move in the opposite directions. Parallax effects are used for making websites better in terms of User Experience and enhancing the interactivity level of the website. We can move the foreground and the background images ...
Read MoreHow to Create Timeline Animations using Anime.js?
In this article, we are going to explore and learn about Timeline Animations. Anime.js is a lightweight JavaScript library that has a small but powerful set of APIs. It works upon the DOM attributes, CSS properties, SVG, and JavaScript objects. We can build multiple and complex animations using the Anime.js. Anime's built-in staggering system helps in making complex follow through and overlapping animations simple. It can also be used on both timings and properties. How to use Anime.js? We can import or use Anime.js in our code in the following two ways: ...
Read MoreHow to Declare an Object with Computed Property Name in JavaScript?
In JavaScript, computed property names allow you to dynamically create object properties using expressions inside square brackets. This ES6 feature provides flexibility when property names need to be determined at runtime. JavaScript Object – A JavaScript object contains key-value pairs where the key represents a property from which we can get and set the value of an object. Using Square Bracket Notation in Object Literals We can use square bracket expressions [] to create computed property names directly in object literals. In ES6, it's possible to use any expression within the brackets. Example 1 In ...
Read MoreHow to Generate a PDF from an HTML Webpage?
Converting HTML content to PDF is a common requirement for web applications. This allows users to save content for offline reading, generate reports, or create downloadable documents. There are two primary approaches to generate PDFs from HTML webpages: Using the browser's native print functionality Using JavaScript libraries like jsPDF Method 1: Using Browser Print Functionality This method leverages the browser's built-in print feature to create a PDF. It opens a new window with the content and triggers the print dialog. Steps: Open a ...
Read MoreHow to Detect if CAPS Lock is ON using JavaScript?
In this article, we are going to explore the CAPS LOCK key and how to check if it is turned on or not using JavaScript on a webpage. While working with modern web applications, we often require information about user interaction and experience. The user interacts with a website to execute functionality like hitting an API, handling clicks or buttons that trigger methods, and many more. In some cases, we might need to know whether the CAPS LOCK key is turned on or not. One use case can be any authentication system that notifies the user that the ...
Read MoreJavaScript: How to Detect if a Website is Open on a Mobile or a Desktop?
We can use the CSS media queries to check whether the website is opened inside a web browser or a mobile browser. This information can be fetched using the min-width and the max-width of the webpage. CSS media queries are only limited to styling the web pages but we can control the functionality of a website as per the user's device by using the navigator properties in JavaScript. The Navigator returns a set of values that includes user browser, version, operating system, and many more. Syntax navigator.userAgent Method 1: Using navigator.userAgent In ...
Read MoreHow to encode and decode a URL in JavaScript?
Encoding and decoding URLs is essential in web development for handling special characters in URLs. When making GET requests to APIs with query parameters, proper encoding ensures URLs are transmitted correctly. Browsers often handle this automatically, but understanding these methods is crucial. For example, a space " " is encoded as %20 or + depending on the context. Understanding URL Encoding Methods JavaScript provides two main functions for URL encoding: encodeURI() − Encodes a complete URI while preserving URL structure characters like :, /, ?, #, &, = encodeURIComponent() ...
Read MoreHow to get Property Descriptors of an Object in JavaScript?
In JavaScript, property descriptors define the behavior and characteristics of object properties. The Object.getOwnPropertyDescriptor() method returns a descriptor object that describes a specific property of an object, including its value and configuration attributes. Syntax Object.getOwnPropertyDescriptor(obj, prop) Parameters obj − The object whose property descriptor you want to retrieve. prop − The name or Symbol of the property whose descriptor you want to retrieve. This method returns a property descriptor object if the property exists, or undefined if it doesn't. Property Descriptor Attributes A ...
Read MoreHow to use JavaScript to play a video on Mouse Hover and pause on Mouseout?
In this article, we will explore how to use event listeners to control video playback with mouse interactions. We'll use the mouseover and mouseout events to automatically play and pause a video when the user hovers over it. The main functionality includes playing the video whenever the mouse hovers over the video element and pausing the video when the mouse leaves the video area. How It Works We attach event listeners to a video element in the DOM. When the browser detects a mouseover event, it triggers a JavaScript function to play the video. Similarly, when a ...
Read MoreHow to use JavaScript to replace a portion of string with another value?
In this article, we are going to explore replacing a portion of a string with another value using JavaScript. We can replace string parts in multiple ways. Below are some common methods − replace() method split() and join() methods replaceAll() method Let's discuss the above methods in detail. Using replace() Method The replace() method is an inbuilt JavaScript method that replaces the first occurrence of a substring or regular expression pattern with a new value. The original string remains unchanged. Syntax ...
Read More