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
Articles by Sravani S
51 articles
Execute a script when a mouse pointer moves out of an element in HTML?
The onmouseout attribute in HTML triggers when the mouse pointer moves away from an element. This event is commonly used for interactive effects like changing colors, hiding tooltips, or resetting element states when the user moves their cursor away. Syntax Following is the syntax for the onmouseout attribute − Content The script can be a JavaScript function call or inline JavaScript code that executes when the mouse pointer leaves the element. Basic Example Following example demonstrates the onmouseout event changing text color when the mouse leaves the heading − ...
Read MoreHow to specify a minimum value in HTML?
The min attribute in HTML is used to specify the minimum allowed value for input elements. This attribute is primarily used with input types like number, range, date, datetime-local, month, time, and week to enforce validation constraints on user input. Syntax Following is the syntax for using the min attribute − Where value represents the minimum acceptable value based on the input type. For numeric inputs, it's a number; for date inputs, it's a date string in the appropriate format. Using Min with Number Input The most common use of the ...
Read MoreSet the width of the element in HTML
The width attribute in HTML sets the width of an element in pixels. This attribute is supported by several HTML elements including , , , , , and . The width attribute provides a quick way to control element dimensions directly in HTML markup. Syntax Following is the syntax for using the width attribute − The value is specified in pixels as a positive integer. For example, width="300" sets the element width to 300 pixels. Elements Supporting Width Attribute The width attribute can be used with the following HTML elements − ...
Read MoreHow to display JavaScript variables in an HTML page without document.write?
Use Element.innerHTML in JavaScript to display JavaScript variables in an HTML page without document.write(). This approach provides better control over content placement and doesn't overwrite the entire page. Basic Example: Displaying Variables Here's how to display JavaScript variables using innerHTML: Display Variables User Information Name: Age: City: // JavaScript variables ...
Read MoreHow to set the shadow effect of a text with JavaScript?
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 MoreHow to define global variable in a JavaScript function?
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 MoreHow to force a number to display in exponential notation?
Use the toExponential() method to force a number to display in exponential notation, even if the number is in the range in which JavaScript normally uses standard notation. Syntax number.toExponential(fractionDigits) Parameters fractionDigits - An optional integer specifying the number of digits after the decimal point. Defaults to as many digits as necessary to specify the number. Return Value Returns a string representing the number in exponential notation. Example: Basic Usage You can force a number to display in exponential notation as follows: ...
Read MoreHTML5 IndexedDB Example
IndexedDB is a powerful client-side database API that allows you to store structured data in the browser. Here's how to add data to an IndexedDB database. Setting Up IndexedDB Before adding data, you need to open a database and create an object store: let db; // Open IndexedDB database const request = indexedDB.open("EmployeeDB", 1); request.onupgradeneeded = function(event) { db = event.target.result; const objectStore = db.createObjectStore("employee", { keyPath: "id" }); console.log("Database setup complete"); }; request.onsuccess = function(event) { ...
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 MorePositioning HTML5 SVG in the center of screen
To center an SVG element horizontally on the screen, you can use CSS properties like margin and display. This technique works by making the SVG a block-level element and setting automatic left and right margins. CSS for Centering SVG Apply the following CSS to center your SVG element: #svgelem { margin-left: auto; margin-right: auto; display: block; } HTML SVG Element Here's the SVG element that we'll center using the above CSS: ...
Read More