Articles on Trending Technologies

Technical articles with clear explanations and examples

Usage of margin-bottom property with CSS

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 15-Mar-2026 93 Views

The margin-bottom CSS property specifies the bottom margin of an element, creating space below it. It accepts values in pixels, percentages, ems, or the keyword auto. Syntax margin-bottom: length | percentage | auto | initial | inherit; Parameters length - Fixed value in px, em, rem, etc. percentage - Relative to parent element's width auto - Browser calculates the margin automatically initial - Sets to default value (0) inherit - Inherits from parent element Example: Basic margin-bottom Usage ...

Read More

Remove elements from a queue using Javascript

Samual Sam
Samual Sam
Updated on 15-Mar-2026 1K+ Views

Dequeuing elements from a Queue means removing them from the front/head of the queue. We are taking the start of the container array to be the head of the queue as we'll perform all operations with respect to it. 10 20 30 40 FRONT REAR ...

Read More

How to stop a function during its execution in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 5K+ Views

In JavaScript, you can stop a function during execution using different techniques depending on the function type. For repeating functions like setInterval(), use clearInterval(). For one-time delayed functions, use clearTimeout(). Stopping setInterval() Functions The most common scenario is stopping a repeating function created with setInterval(): Stop Function Execution Start Function Stop Function ...

Read More

Replacing array of object property name in JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 474 Views

In JavaScript, you can replace property names in an array of objects using the map() method to create new objects with renamed properties. This technique is useful when you need to transform data structures or adapt objects to different naming conventions. Syntax const newArray = originalArray.map(item => ({ newPropertyName: item.oldPropertyName, // ... other properties })); Example: Renaming Object Properties Replace Object Property Names ...

Read More

Validate input: replace all 'a' with '@' and 'i' with '!'JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 161 Views

We need to write a function validate() that takes a string as input and returns a new string where all occurrences of 'a' are replaced with '@' and all occurrences of 'i' are replaced with '!'. This is a classic string manipulation problem that can be solved using different approaches. Let's explore the most common methods. Using For Loop The traditional approach iterates through each character and builds a new string: const string = 'Hello, is it raining in Amsterdam?'; const validate = (str) => { let validatedString = ''; ...

Read More

Lose input hints (get focus) after pressing mouse cursor in a textbox with JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 490 Views

In this tutorial, we'll learn how to clear placeholder-like text from an input field when the user clicks on it (gets focus) and restore it when the field loses focus if no text was entered. Let's say we have the following input field with hint text: StudentName: To lose input hints on pressing mouse cursor, we use the onfocus and onblur events. How It Works The solution uses two JavaScript functions: onfocus: Clears the hint text when user clicks in the field onblur: Restores hint ...

Read More

How to get the value of the type attribute of a link in JavaScript?

Paul Richard
Paul Richard
Updated on 15-Mar-2026 617 Views

To get the value of the type attribute of a link in JavaScript, use the type property. The type attribute specifies the MIME type of the linked document, such as "text/html" for HTML documents or "text/css" for stylesheets. Syntax element.type Example: Getting Link Type Attribute You can access the type attribute of a link using getElementById() and the type property: TutorialsPoint var myVal = document.getElementById("anchorid").type; console.log("Value ...

Read More

How to set the left margin of an element with JavaScript?

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

In this tutorial, we will learn how to set the left margin of an element with JavaScript. Margin is the space around an element outside its border. The margin of an element can be on all sides, such as: left, right, top, and bottom. Use the marginLeft property in JavaScript to set the left margin. In this tutorial, we will discuss two approaches to setting the left margin − Using the marginLeft property Using the setProperty method Using the marginLeft property to set the left margin of an ...

Read More

How to rotate an image with the canvas HTML5 element from the bottom center angle?

Smita Kapse
Smita Kapse
Updated on 15-Mar-2026 382 Views

Rotating an image from the bottom center in HTML5 Canvas requires translating the canvas origin to the rotation point, applying the rotation, then drawing the image at an offset position. Understanding Canvas Rotation Canvas rotation always occurs around the origin (0, 0). To rotate from a specific point like bottom center, we must: Translate the canvas to the rotation point Apply the rotation Draw the image at an adjusted position Complete Example const canvas = document.getElementById('myCanvas'); const context = canvas.getContext('2d'); // Create an image const img = new ...

Read More

Making an image scale mouse over on HTM5

Samual Sam
Samual Sam
Updated on 15-Mar-2026 384 Views

To make an image scale on mouse over in HTML5, you can use CSS transforms or Canvas API. Here we'll show both approaches for creating smooth scaling effects. Method 1: Using CSS Transform (Recommended) The simplest approach uses CSS transform: scale() with :hover pseudo-class: .scalable-image { width: 200px; height: 200px; ...

Read More
Showing 17551–17560 of 61,297 articles
Advertisements