Web Development Articles

Page 295 of 801

How to convert special characters to HTML in Javascript?

Saurabh Anand
Saurabh Anand
Updated on 15-Mar-2026 6K+ Views

Special characters like , and & have special meaning in HTML and can break your webpage if not properly escaped. JavaScript provides several methods to convert these characters into their HTML entity equivalents. Why Convert Special Characters to HTML? When displaying user input or dynamic content on a webpage, special characters can cause problems. For example, if you want to display "" as text, the browser might interpret it as an actual HTML tag. Converting these characters to HTML entities like ensures they display as intended text. Common characters that need escaping: ...

Read More

How to convert UTC date time into local date time using JavaScript?

Saurabh Anand
Saurabh Anand
Updated on 15-Mar-2026 32K+ Views

Timezone handling is an essential component of every web application. The time that is recorded in the backend is usually in UTC format. When it is displayed to the user, however, it must be converted to the user's local time. This is possible with JavaScript. We'll look at how to use JavaScript to convert UTC date time to local date time in this blog. JavaScript Date Object JavaScript includes a "Date" object that allows us to work with dates and times. The Date object includes various methods for working with dates and times, including: ...

Read More

How to count text lines inside of a DOM element?

Saurabh Anand
Saurabh Anand
Updated on 15-Mar-2026 3K+ Views

Introduction The DOM (Document Object Model) is an API for HTML and XML documents that provides programmers control over a webpage's structure, appearance, and content. Counting text lines within DOM elements is useful for layout calculations, pagination, and content management. This article explores three methods to count text lines in DOM elements using JavaScript. Method 1: Using the scrollHeight Property The scrollHeight property returns the total height of an element, including content hidden by overflow. We can calculate the number of lines by dividing scrollHeight by the height of a single line of text. ...

Read More

How to count the number of times a button is clicked using JavaScript?

Saurabh Anand
Saurabh Anand
Updated on 15-Mar-2026 18K+ Views

Tracking button clicks is a common task in JavaScript and can be achieved by using the addEventListener() method. By adding an event handler to the button element and incrementing a variable each time the button is pressed, we can keep track of button clicks. We can display the count to users and even persist clicks using localStorage so they remain after browser closure. This technique is essential for interactive web applications like calculators, games, or analytics tracking. Let's explore different methods to count button clicks effectively. Creating a Basic Button First, we need a button element on ...

Read More

How to create 3D Geometries in webGL and p5.js?

Saurabh Anand
Saurabh Anand
Updated on 15-Mar-2026 950 Views

Creating 3D geometries in WebGL and p5.js enables developers to build interactive and visually compelling web applications. With built-in functions for basic shapes, texture mapping, and transformations, both libraries provide powerful tools for 3D graphics development. Understanding WebGL vs p5.js for 3D Graphics WebGL is a low-level graphics API that provides direct access to the GPU, while p5.js offers a higher-level, artist-friendly interface. For complex 3D applications, Three.js (built on WebGL) is often preferred, whereas p5.js excels in creative coding and educational contexts. Creating Basic 3D Shapes Using Three.js (WebGL-based) Three.js simplifies WebGL by providing ...

Read More

How to create the previous and next buttons and non-working on the end positions using JavaScript?

Dishebh Bhayana
Dishebh Bhayana
Updated on 15-Mar-2026 1K+ Views

We can create previous and next buttons that are disabled at their end positions using vanilla JavaScript. JavaScript allows us to control and manipulate DOM elements easily. Here, we will create navigation buttons and change an HTML element's content depending on which button is clicked. Example 1: Counter with Disabled States In this example, we will create "Next" and "Previous" buttons that increment and decrement a counter. The buttons will be disabled when they reach their extreme positions (0 for Previous and 5 for Next). Previous and Next Buttons with ...

Read More

How to create regular expression only accept special formula?

Rushi Javiya
Rushi Javiya
Updated on 15-Mar-2026 1K+ Views

Regular expressions are powerful patterns used to validate and match specific text formats. In this tutorial, we'll learn how to create regular expressions that validate mathematical formulas containing various operators and formats. Basic Formula Validation Let's start with a simple regular expression that accepts basic mathematical formulas with addition and subtraction operators. Syntax let regex = /^\d+([-+]\d+)*$/g; This regex accepts formulas like "10-13+12+23" with no spaces between operators and numbers. Regular Expression Breakdown ^ – Represents the start of the string \d+ – Matches one or more digits at the ...

Read More

How to set cursor position in content-editable element using JavaScript?

Rushi Javiya
Rushi Javiya
Updated on 15-Mar-2026 12K+ Views

In HTML, content editable div allows users to edit the content of the div element. We need to pass the contenteditable attribute with true Boolean value to the div element to make any div element editable. The content editable div contains the caret cursor by default, and sometimes we may require to set the caret cursor position in the content editable div element to edit the content of the div. However, we can set the caret cursor position anywhere by clicking at a particular place in the content editable div. This tutorial will teach us to use different ...

Read More

How to set cursor style to pointer for links without href?

Rushi Javiya
Rushi Javiya
Updated on 15-Mar-2026 3K+ Views

We can use the tag in HTML to add a link to the web page. The default cursor style for the elements is the pointer, but removing the href attribute from the tag changes the cursor style. So, in this tutorial, we will learn to keep the cursor style to pointer for tags without the href attribute. Users can follow the example below to check out the default cursor style for the elements. Default Behavior Example In the example below, we have used the tag to create three different links. ...

Read More

How to set default values when destructuring an object in JavaScript?

Rushi Javiya
Rushi Javiya
Updated on 15-Mar-2026 6K+ Views

The array and object destructuring feature was introduced in the ES6 version of JavaScript. The destructuring of the array and object allows us to store its values in a separate variable. After that, we can use that variable to access the value of the particular property of the object. The main thing we need to focus on while destructuring the array object is the default values. For example, we have added the property3 variable in the destructuring object, but if the object doesn't contain the property3, destructuring sets the undefined value to the property3 variable. Users can follow ...

Read More
Showing 2941–2950 of 8,010 articles
« Prev 1 293 294 295 296 297 801 Next »
Advertisements