Shubham Vora

Shubham Vora

793 Articles Published

Articles by Shubham Vora

Page 18 of 80

How to convert a decimal number to roman using JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 984 Views

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 More

How can I escape HTML special chars in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 10K+ Views

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 More

How to work with Structs in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 8K+ Views

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 More

How to set the color of the rule between columns with JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 269 Views

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 More

How to get the id of a form containing a dropdown list with JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 5K+ Views

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 More

How to set the font family for text with JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 8K+ Views

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 More

How to get the number of options in the dropdown list with JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 11K+ Views

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 More

How to center the JavaScript alert message box?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 10K+ Views

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 More

How to display the selected option in a dropdown list with JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 33K+ Views

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 More

How to set the gap between the columns with JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 2K+ Views

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
Showing 171–180 of 793 articles
« Prev 1 16 17 18 19 20 80 Next »
Advertisements