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 Shubham Vora
Page 18 of 80
How to convert a decimal number to roman using JavaScript?
Roman numerals are a number system that uses letters from the Latin alphabet to represent values. In this tutorial, you'll learn how to convert decimal numbers to Roman numerals using JavaScript. Roman Numeral Symbols Seven basic symbols form Roman numerals: I = 1 V = 5 X = 10 L = 50 C = 100 D = 500 M = 1000 Additionally, subtractive combinations are used for specific values: IV = 4 IX = 9 XL = 40 XC = 90 CD = 400 CM = 900 Algorithm The ...
Read MoreHow can I escape HTML special chars in JavaScript?
HTML contains special characters such as '', '/' and many more such as single and double quotes. These special characters are used for HTML tags, such as '' are used to close HTML tags. This tutorial teaches us to escape HTML special characters in JavaScript. Now, the question is what if we want to use these characters inside the HTML content? If we use special characters normally in HTML content, it considers them as opening or closing HTML tags and produces an unknown error. For example, we need to render the below string to the browser: ...
Read MoreHow to work with Structs in JavaScript?
In this tutorial, let us discuss how to work with structs in JavaScript. What is a struct? A struct is the short name of the data structure. The structure creates multiple values of different types in a single variable. We can use a struct to generate records. JavaScript doesn't have built-in struct support like C or C++. However, we can simulate struct-like behavior using JavaScript objects and constructor functions. Let us see the methods to create a structure. Using the String split() Method We can create a struct constructor dynamically by parsing a comma-separated string of ...
Read MoreHow to set the color of the rule between columns with JavaScript?
In this tutorial, we will learn how to set the color of the rule between columns with JavaScript. Multiple columns are used to increase the readability of long paragraphs or articles. The column-count CSS property is used to divide the text into columns. To set the color of the rule between columns with JavaScript, we use the columnRuleColor property of the style object. Using the style.columnRuleColor Property In JavaScript, the style.columnRuleColor property of an element is used to set the color of the rule between columns. We can set colors using color names, hex codes, or RGB ...
Read MoreHow to get the id of a form containing a dropdown list with JavaScript?
In this tutorial, we will learn how to get the id of a form containing a dropdown list using JavaScript. The id property of an HTML element provides a unique identifier. The id property value must be unique within the HTML document. JavaScript uses it to access and manipulate elements with the specified id. A dropdown menu (also called a select element) provides a list of options where users can choose one item from multiple available options. Following are the methods to get the id of a form containing a dropdown list with JavaScript: Using the ...
Read MoreHow to set the font family for text with JavaScript?
In this tutorial, we will learn how to set the font family for text with JavaScript. The font-family is a CSS property that specifies a prioritized list containing one or more font family names and generic family names for the text of an HTML element. To set the font-family for text with JavaScript, we have multiple ways, and in this tutorial, we will discuss two of them − Using the style.fontFamily Property Using the style.setProperty Method Using the style.fontFamily Property The style.fontFamily property sets a list of font ...
Read MoreHow to get the number of options in the dropdown list with JavaScript?
This tutorial shows different ways to get the number of options in a dropdown list using JavaScript. When working with HTML forms, you may need to count dropdown options for validation or dynamic functionality. A dropdown list is created using the tag with multiple elements. JavaScript provides several methods to count these options programmatically. Using options.length Property The most straightforward method is accessing the options.length property of a select element. First, get the select element by its ID, then use the options.length property. Syntax var selectElement = document.getElementById("dropdown"); var optionCount = selectElement.options.length; ...
Read MoreHow to center the JavaScript alert message box?
In this tutorial, we will learn to center the JavaScript alert box. In JavaScript, an alert box is useful to show users some message, information, warning, success, etc. Let's understand it by real-world example when you open any website on the web browser and start to authenticate by entering your username and password. When you click the submit button, it gives a message in an alert box like the password should be 8 or more characters, or sign in successfully. Users can create the alert box using JavaScript's alert() method. Unfortunately, the default alert box doesn't allow us to ...
Read MoreHow to display the selected option in a dropdown list with JavaScript?
In this tutorial, we will learn how to display the selected option in a dropdown list with JavaScript. A dropdown list is a switchable menu that enables users to select one item from various options. It's created using the tag and is commonly used in forms to gather user input. The DOM API functions getElementById() and querySelector() can be used to access a element and retrieve its selected value. Let's explore the different methods to display the selected option. Using selectedIndex Property The selectedIndex property returns the index of the currently selected option in ...
Read MoreHow to set the gap between the columns with JavaScript?
In this tutorial, we will learn how to set the gap between the columns with JavaScript. The readability of lengthy paragraphs or articles is improved by dividing them into multiple columns. The text is divided into multiple columns using the 'column-count' CSS property. There needs to be a space or gap between the columns to make each column separate from the other. To set the gap between the columns with JavaScript, we have multiple ways, and in this tutorial, we will discuss two of them − Using the style.columnGap property ...
Read More