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
HTML Articles
Page 126 of 151
How to search the alternate text of an image-map area in JavaScript?
To search the alternate (alt) text of an image-map area in JavaScript, use the alt property. This property allows you to access or modify the alternative text that describes the image map area for accessibility purposes. Syntax // Get alt text let altText = areaElement.alt; // Set alt text areaElement.alt = "new alt text"; Example: Accessing Alt Text of Image Map Area ...
Read MoreWhat is the role of scrollX property in JavaScript?
The scrollX property in JavaScript returns the number of pixels the document has been scrolled horizontally from the left edge of the viewport. It's equivalent to the older pageXOffset property and is read-only. Syntax let horizontalScroll = window.scrollX; Return Value Returns a number representing the horizontal scroll position in pixels. The value is 0 when the document is not scrolled horizontally. Example: Basic scrollX Usage .content { ...
Read MoreHow to search and display the pathname part of the href attribute of an area with JavaScript?
To get the pathname part of the href attribute of an area in JavaScript, use the pathname property. This property extracts just the path portion from a URL, excluding the protocol, domain, and query parameters. Syntax areaElement.pathname Example You can try to run the following code to display the pathname part of an area element's href attribute. ...
Read MoreWhat is the usage of an abort event in JavaScript?
The abort event fires when the loading of a media resource is aborted, typically for images, videos, or audio elements. This event occurs when the user navigates away from the page or explicitly stops the loading process before it completes. When the abort Event Occurs The abort event is triggered in several scenarios: User navigates away from the page while an image is loading Loading is interrupted by clicking a link or refreshing the page Network connection is lost during resource loading The loading process is programmatically canceled Example: Basic abort Event Handler ...
Read MoreWhat will happen when 0 is converted to Number in JavaScript?
Use the Number() method in JavaScript to convert values to Number type. When converting 0 to Number, it remains 0 since it's already a valid number. Basic Conversion Converting 0 to Number returns 0, as zero is already a number: Convert 0 to Number var myVal = 0; document.write("Number: " + Number(myVal)); ...
Read MoreHow to stop the execution of a function with JavaScript?
To stop the execution of a function in JavaScript, you have several methods depending on the type of execution. The most common approaches involve clearing timers or using control flow statements. Using clearTimeout() for setTimeout() The clearTimeout() method stops functions scheduled with setTimeout(): Stop Function Execution Click the buttons below to handle animation Start Stop var ...
Read MoreWhat will happen when 1 is converted to Boolean in JavaScript?
In JavaScript, when the number 1 is converted to Boolean, it becomes true. This is because 1 is considered a "truthy" value in JavaScript's type conversion system. Understanding Truthy and Falsy Values JavaScript has specific rules for Boolean conversion. The number 1 (and all non-zero numbers) are truthy values, meaning they convert to true. Example: Converting 1 to Boolean Convert 1 to Boolean var myVal = 1; document.write("Boolean: " ...
Read MoreWhat is the usage of onhashchange event in JavaScript?
The onhashchange event occurs when the anchor part (hash) of the URL changes. This event is useful for creating single-page applications where different URL fragments represent different views or states. Syntax window.onhashchange = function() { // Code to execute when hash changes }; // Or using addEventListener window.addEventListener('hashchange', function() { // Code to execute when hash changes }); Example: Basic Hash Change Detection Change to #about Change to #contact ...
Read MoreHow to set all the border bottom properties in one declaration in JavaScript DOM?
To set all border bottom properties in one declaration using JavaScript DOM, use the borderBottom property. This property allows you to simultaneously set the border-bottom-width, border-bottom-style, and border-bottom-color in a single statement. Syntax element.style.borderBottom = "width style color"; Parameters The borderBottom property accepts a string value containing three space-separated components: width: Border thickness (e.g., "thin", "medium", "thick", "2px", "5px") style: Border style (e.g., "solid", "dashed", "dotted", "double") color: Border color (e.g., "red", "#ff0000", "rgb(255, 0, 0)") Example Here's how to set border bottom properties using JavaScript: ...
Read MoreWhat is the usage of the onbeforeunload event in JavaScript?
The onbeforeunload event triggers when a user attempts to leave the page, such as closing the tab, refreshing, or navigating to another URL. It's commonly used to warn users about unsaved changes. Syntax window.onbeforeunload = function(event) { // Return a string to show confirmation dialog return "Your message here"; }; // Or using addEventListener window.addEventListener('beforeunload', function(event) { event.preventDefault(); event.returnValue = ''; }); Example: Basic Implementation onbeforeunload Example ...
Read More