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 radhakrishna
Page 2 of 7
What is onkeypress event in JavaScript?
The onkeypress event in JavaScript triggers when a user presses and releases a key while an element has focus. This event is commonly used with input fields, text areas, and other interactive elements to respond to user keyboard input. Syntax element.onkeypress = function(event) { // Handle keypress }; // Or in HTML Basic Example Here's how to use the onkeypress event to detect when a key is pressed in an input field: ...
Read MoreSet the font style with CSS
To set the font style, use the font-style property. This CSS property allows you to make text appear italic, normal, or oblique. Syntax font-style: normal | italic | oblique; Values normal - Default font style (upright text) italic - Slanted version of the font (if available) oblique - Artificially slanted text Example: Italic Font Style You can try to run the following code to set the font-style to italic with CSS: Font Style Example ...
Read MoreHow to set cookies expiry date in JavaScript?
Setting an expiration date for cookies allows them to persist beyond the current browser session. Without an expiration date, cookies are deleted when the browser closes. You can set the expiry date using the expires attribute in the cookie string. Syntax document.cookie = "name=value; expires=date; path=/"; Setting Cookie with 1 Month Expiry Here's how to create a cookie that expires after one month: function WriteCookie() { var now = new Date(); ...
Read MoreWhat is super() function in JavaScript?
The super() function in JavaScript is used to call the constructor of the parent class and access methods from the parent class within a child class. It's essential for proper inheritance in ES6 classes. Syntax super() // Call parent constructor super.method() // Call parent method Using super() in Constructor When extending a class, you must call super() before using this in the child constructor: ...
Read MoreHow to detect if JavaScript is disabled in a browser?
To detect if JavaScript is disabled in a web browser, you can use several approaches. The most common method is the HTML tag, which displays content only when JavaScript is unavailable. Using the Tag The tag provides fallback content for browsers that don't support JavaScript or have it disabled: JavaScript Detection document.write("JavaScript is enabled!"); ...
Read MoreWhat is the difference between comments /*...*/ and /**...*/ in JavaScript?
In JavaScript, both /*...*/ and /**...*/ create multi-line comments, but they serve different purposes. The key difference is that /**...*/ is specifically used for documentation comments (JSDoc), while /*...*/ is for regular multi-line comments. Regular Multi-line Comments (/*...*/) Standard multi-line comments are used for general code documentation and explanations: /* * This is a regular multi-line comment * Used for general code explanations * Similar to C-style comments */ function calculateArea(width, height) { return width * height; } JSDoc Documentation Comments (/**...*/) JSDoc comments start ...
Read MoreWhat is the relationship between JavaScript, CoffeeScript, TypeScript, ES5, and ES6?
JavaScript serves as the foundation for web development, with several related languages and versions that enhance or extend its capabilities. Understanding their relationships helps developers choose the right tools for their projects. JavaScript (The Foundation) JavaScript is the core programming language that runs in browsers and Node.js environments. All other languages mentioned either extend JavaScript or compile to it. // Basic JavaScript function greet(name) { return "Hello, " + name + "!"; } console.log(greet("World")); Hello, World! ES5 vs ES6 (JavaScript Versions) ES5 (ECMAScript 5) and ...
Read MoreUsage of CSS grid-auto-flow property
The CSS grid-auto-flow property controls how auto-placed items are inserted in the grid container. It determines whether new items are placed in rows or columns and the direction of placement. Syntax selector { grid-auto-flow: value; } Possible Values ValueDescription rowAuto-placed items fill rows first (default) columnAuto-placed items fill columns first row denseFill rows and pack items densely column denseFill columns and pack items densely Example 1: Column Flow The following example uses grid-auto-flow: column to place items in columns − ...
Read MoreAnimate CSS column-gap property
The CSS column-gap property is used to set the gap between columns in a multi-column layout. When combined with CSS animations, you can create smooth transitions that adjust the spacing between columns over time. Syntax selector { column-gap: value; animation: animation-name duration timing-function iteration-count; } @keyframes animation-name { percentage { column-gap: new-value; } } Example The following example demonstrates how to animate the column-gap property to create a dynamic ...
Read MoreSet a delay for the start of an animation with CSS
The CSS animation-delay property is used to set a delay before an animation starts. This property allows you to control when an animation begins, creating staggered effects or waiting for user interactions. Syntax selector { animation-delay: time; } Possible Values ValueDescription timeSpecifies the delay time in seconds (s) or milliseconds (ms) 0Default value - no delay Negative valuesAnimation starts immediately but partway through the animation cycle Example: Basic Animation Delay The following example demonstrates a 2-second delay before the animation starts − ...
Read More