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
Programming Scripts Articles
Page 10 of 33
How 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 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 MoreHow to get the value of the usemap attribute of an image with JavaScript?
To get the value of the usemap attribute of an image, use the useMap property. This property returns the value of the usemap attribute, which specifies which image map to use with the image. Syntax let value = imageElement.useMap; Example ...
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 MoreFlexbox and vertical scroll in a full-height app using newer Flexbox API with HTML
The flex property is a shorthand for the flex-grow, flex-shrink, and flex-basis properties. The flex property sets the flexible length on flexible items. When creating full-height applications with scrollable content areas, proper flexbox configuration is essential. Basic Flexbox Scroll Setup To create a scrollable flex item that takes up remaining space, use flex: 1 1 auto with overflow-y: auto: #container { display: flex; flex-direction: column; height: 100vh; } #container article { flex: 1 1 auto; ...
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 MoreHTML5 Canvas distorted
HTML5 Canvas distortion occurs when the canvas element's CSS dimensions don't match its internal drawing dimensions. This creates scaling issues that make drawings appear stretched or blurry. Understanding Canvas Dimensions Canvas has two sets of dimensions: Drawing dimensions: Set via width and height attributes Display dimensions: Set via CSS width and height properties When these don't match, the browser scales the drawing surface to fit the display size, causing distortion. Default Canvas Size The default canvas dimensions are: width = 300px height = 150px This gives a 2:1 aspect ...
Read MoreWhat is the usage of onscroll event in JavaScript?
The onscroll event in JavaScript occurs when an element's scrollbar is being scrolled. This event is commonly used to create interactive features like scroll-triggered animations, infinite scrolling, or scroll position indicators. Syntax element.onscroll = function() { // Code to execute when scrolling }; // Or using addEventListener element.addEventListener('scroll', function() { // Code to execute when scrolling }); Basic Example Here's a simple example showing how to detect when a div element is scrolled: ...
Read MoreSharedArrayBuffer.byteLength Property in JavaScript
The byteLength property of the SharedArrayBuffer returns an unsigned, 32-bit integer that specifies the size/length of a SharedArrayBuffer in bytes. Syntax sharedArrayBuffer.byteLength Parameters This property takes no parameters and is read-only. Return Value Returns the length of the SharedArrayBuffer in bytes as a 32-bit unsigned integer. Example JavaScript Example var sharedArrayBuffer = new SharedArrayBuffer(8); ...
Read MoreWhat is the usage of onblur event in JavaScript?
The onblur event in JavaScript triggers when an HTML element loses focus. This commonly occurs when users click away from an input field, tab to another element, or programmatically change focus. Syntax // OR element.onblur = function() { /* code */ }; // OR element.addEventListener('blur', function() { /* code */ }); Example: Input Field Validation Enter your email and click outside the field: ...
Read More