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
Javascript Articles
Page 291 of 534
How to preselect Dropdown Using JavaScript Programmatically?
In this tutorial, we will learn how to preselect dropdown options using JavaScript programmatically. This is useful when you want to set default selections based on user preferences, data from APIs, or other dynamic conditions. A dropdown list is a toggle menu that allows users to select one option from multiple choices. In HTML, dropdown lists are created using the element combined with elements. JavaScript provides several methods to programmatically control these selections. There are two primary methods to preselect dropdown options: using the selectedIndex property and using the value property. Let's explore both approaches. ...
Read MoreHow to draw a star in HTML5 SVG?
SVG stands for Scalable Vector Graphics and is a language for describing 2D-graphics and graphical applications in XML. Most web browsers can display SVG just like they can display PNG, GIF, and JPG. To draw a star in HTML5 SVG, we use the element. The key is to set the correct x and y coordinates for each point of the star, alternating between outer points (tips) and inner points (valleys). 5-Point Star using SVG Polygon ...
Read MoreCreate a small-caps effect for CSS
To create a small-caps effect in CSS, use the font-variant property with the value small-caps. This transforms lowercase letters into smaller uppercase letters while keeping original uppercase letters at their normal size. Syntax font-variant: small-caps; Example Here's how to apply the small-caps effect to text: .small-caps { font-variant: small-caps; font-size: 18px; ...
Read MoreHow to use JavaScript to redirect an HTML page?
You might have encountered a situation where you clicked a URL to reach a page X but internally you were directed to another page Y. It happens due to page redirection. JavaScript provides several methods to redirect users from one page to another. This is commonly used for routing users after form submissions, authentication, or when content has moved to a new location. Methods for Page Redirection There are three main ways to redirect pages using JavaScript: Using window.location.href The most common method assigns a new URL to window.location.href: ...
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 use Meta Tag to redirect an HTML page?
Page redirection is a situation where you clicked a URL to reach a page X but internally you were directed to another page Y. It happens due to page redirection. To use a META Tag to redirect your site is quite easy. With this, use the http-equiv attribute to provide an HTTP header for the value of the content attribute. ...
Read MoreHow to fix problems related to the JavaScript Void 0 Error?
The JavaScript "void(0)" error typically occurs when JavaScript is disabled in the browser or when there are issues with JavaScript execution. This error commonly appears as "javascript:void(0)" in links or when scripts fail to run properly. What is JavaScript void(0)? The void operator in JavaScript evaluates an expression and returns undefined. When used as void(0) or void 0, it simply returns undefined without executing any meaningful operation. console.log(void(0)); // undefined console.log(void 0); // undefined console.log(void(1 + 2)); ...
Read MoreUsage of font-style property in CSS
The font-style property in CSS is used to specify whether text should be displayed in normal, italic, or oblique style. This property allows you to add emphasis to text by changing its visual appearance. Syntax font-style: normal | italic | oblique; Values normal - Default value. Text is displayed normally italic - Text is displayed in italic style (slanted) oblique - Text is displayed in oblique style (artificially slanted) Example: Basic Font Style Usage ...
Read MoreHow can I force clients to refresh JavaScript files?
When you update JavaScript files on your server, browsers may still load the old cached version instead of your new code. This tutorial shows you how to force browsers to reload updated JavaScript files automatically. The problem occurs because browsers cache JavaScript files locally for faster loading. When you deploy new code, browsers continue serving the old cached files instead of fetching updated ones from the server. This causes users to see outdated functionality even after you've deployed new features or fixes. Understanding Browser Caching When users visit your application, browsers store CSS and JavaScript files in ...
Read MoreSet the font variant with CSS
The CSS font-variant property controls how text is displayed, allowing you to transform lowercase letters into small capital letters or display text normally. Syntax font-variant: normal | small-caps | inherit; Parameters Value Description normal Default value. Text displays normally small-caps Converts lowercase letters to small capital letters inherit Inherits the font-variant from parent element Example: Using small-caps .small-caps { ...
Read More