Javascript Articles

Page 276 of 534

How to search the alternate text of an image-map area in JavaScript?

Sravani S
Sravani S
Updated on 15-Mar-2026 211 Views

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 More

How to search and display the pathname part of the href attribute of an area with JavaScript?

Vrundesha Joshi
Vrundesha Joshi
Updated on 15-Mar-2026 201 Views

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 More

What will happen when 0 is converted to Number in JavaScript?

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 161 Views

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 More

What will happen when 1 is converted to Boolean in JavaScript?

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

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 More

How to set all the border bottom properties in one declaration in JavaScript DOM?

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

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 More

How to get the value of the usemap attribute of an image with JavaScript?

Sravani S
Sravani S
Updated on 15-Mar-2026 259 Views

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 More

How to set the shadow effect of a text with JavaScript?

Sravani S
Sravani S
Updated on 15-Mar-2026 1K+ Views

The textShadow property in JavaScript allows you to add shadow effects to text elements. This property accepts values for horizontal offset, vertical offset, blur radius, and color. Syntax element.style.textShadow = "h-shadow v-shadow blur-radius color"; Parameters h-shadow: Horizontal offset of the shadow (required) v-shadow: Vertical offset of the shadow (required) blur-radius: Blur distance of the shadow (optional) color: Color of the shadow (optional) Example: Basic Text Shadow Add Text Shadow Remove Shadow ...

Read More

How to define global variable in a JavaScript function?

Sravani S
Sravani S
Updated on 15-Mar-2026 481 Views

In JavaScript, you can define global variables either at global scope or from within functions using the window object. Here are the main approaches. Method 1: Declaring at Global Scope The most straightforward way is to declare variables outside any function at global scope: var myGlobalVariable = "I'm global!"; function display() { console.log(myGlobalVariable); // Accessible here } display(); console.log(myGlobalVariable); // Also accessible here ...

Read More

Why does the JavaScript need to start with ";"?

Ramu Prasad
Ramu Prasad
Updated on 15-Mar-2026 208 Views

JavaScript uses semicolons (;) to separate statements and avoid potential issues with automatic semicolon insertion (ASI). Starting lines with semicolons is a defensive programming practice. The Problem Without Semicolons JavaScript automatically inserts semicolons at line breaks, but this can cause unexpected behavior when lines are concatenated: // Without defensive semicolon let result = getValue() (function() { console.log("This might not work as expected"); })(); function getValue() { return "Hello"; } JavaScript interprets this as calling getValue() with a function as an argument, which causes an error. ...

Read More

Set how much the item will grow relative to the rest of JavaScript.

Priya Pallavi
Priya Pallavi
Updated on 15-Mar-2026 133 Views

Use the flexGrow property to set how much the item will grow relative to the rest of the flexible items with JavaScript. Syntax element.style.flexGrow = "value"; Parameters The flexGrow property accepts a numeric value that defines the growth factor: 0 - Item won't grow (default) 1 - Item grows equally with other flex items 2 or higher - Item grows proportionally more than others Example You can try to run the following code to learn how to work with flexGrow ...

Read More
Showing 2751–2760 of 5,340 articles
« Prev 1 274 275 276 277 278 534 Next »
Advertisements