Found 6685 Articles for Javascript

How to create regular expression only accept special formula?

Rushi Javiya
Updated on 22-Feb-2023 14:56:47

788 Views

The regular expression is a pattern containing various characters. We can use the regular expression to search whether a string contains a particular pattern. Here, we will learn to create a regular expression to validate the various mathematical formulas. We will use the test() or match() method to check if particular mathematical formula matches with regular expression or not Syntax Users can follow the syntax below to create regular expressions accepting special mathematical formulas. let regex = /^\d+([-+]\d+)*$/g; The above regex accepts only 10 – 13 + 12 + 23, like mathematical formulas. Regular Expression ... Read More

How to create dynamic breadcrumbs using JavaScript?

Rushi Javiya
Updated on 01-Mar-2023 10:51:47

3K+ Views

The breadcrumbs help website users to understand the navigation path, and windows file explorer is the best example that provides the breadcrumbs. When you open a file explorer, you can see the current location in the file explorer at the top bar. Also, if you click on any location, it jumps to that location. There are two main benefits of using dynamic breadcrumbs on the website. The first is that users can know about the navigation path, and another is users can jump on any location directly in the navigation path. Here, we will see different approaches to ... Read More

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

Dishebh Bhayana
Updated on 22-Feb-2023 11:35:10

809 Views

We can create previous and next buttons that would be non-working (or disabled) at their end positions by using vanilla javascript. Javascript is a powerful browser-level language with which we can control and manipulate the DOM elements easily. Here, we will create 2 buttons, and change an HTML element’s content depending on which button is clicked. Example 1 In this example, we will create an “increment” and a “decrement” button which, when clicked, will increment and decrement the HTML element’s content value by 1, respectively. We will also disable the buttons when they reach their extreme positions, which will be ... Read More

How to Change the Background Color of a Div on Mouse Move Over using JavaScript?

Gungi Mahesh
Updated on 21-Feb-2023 15:51:24

3K+ Views

The mouseover event is used in the JavaScript code to change the color of background to an elements of HTML. We also want to restore the color to blue after removing our mouse from the element. As a result, we have also used the mouseout event. This will happen when we remove our mouse pointer from the element. getElementById() produces an object of element which represents the element whose id attribute matches the provided string. Because element IDs must be unique if supplied, they're a convenient method to rapidly retrieve a single element. The addEventListener() function is employed to ... Read More

How to create a button that submits a form and downloads a pdf simultaneously?

Saurabh Anand
Updated on 21-Feb-2023 17:33:07

3K+ Views

By using HTML, JavaScript and jsPDF, we can create a button that can submit the form and download a pdf simultaneously. We will use HTML to create a form, JavaScript to handle the submission process and jsPDF to generate the PDF document. The act of submitting a form and getting a PDF is among the most frequent use cases. On the internet, PDFs are a common format for documents. They may be used to keep track of contracts, invoices, and other crucial data. In many instances, submitting a form is required before receiving a PDF. Let’s discuss the complete procedure ... Read More

How to Create a Binary Calculator using HTML, CSS and JavaScript?

Saurabh Anand
Updated on 21-Feb-2023 17:29:03

856 Views

A binary calculator is a program that performs mathematical calculation on binary numbers. Now, as of you remember the binary numbers are those numbers which are formed from only two numbers i.e., 0 and 1. In this blog, we will use this program to calculate addition, subtraction, multiplication and division on binary numbers. This will be a basic calculator that will use basic concepts of HTML, CSS and JavaScript to do the same. So, let’s get started with the HTML structure. HTML Structure Firstly, we will make a form which will be divided into table rows giving features like ... Read More

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

Saurabh Anand
Updated on 21-Feb-2023 17:27:50

615 Views

Creating 3D geometries in webGL and p5.js is a powerful way to create interactive and visually interesting web applications. With the ability to create basic shapes, add textures, lighting, and materials, and transform 3D geometries, we can create a wide range of 3D graphics and animations. By understanding the basics of webGL and p5.js, we can create stunning 3D geometries for their web applications. 3D Shapes creation The first step is to generate some 3D geometries using webGL and p5.js built-in functions. These shapes can be produced using the library's built-in methods, such as sphere(), box(), and cylinder(). ... Read More

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

Saurabh Anand
Updated on 21-Feb-2023 17:26:33

15K+ Views

Tracking button clicks is a common task in JavaScript and can be achieved by using the addEventListener() method. By adding an event handler method to the button element and incrementing a variable each time the button is pressed, we can simply keep track of button clicks. We can quickly show the user how many clicks there have been by showing that information on a web page and keeping the clicks in localStorage. We can even save the clicks even after the user shuts the browser. Suppose we are building a simple calculator then we will need buttons that can ... Read More

How to count text lines inside of a DOM element?

Saurabh Anand
Updated on 21-Feb-2023 17:21:47

2K+ Views

Introduction Before understanding the counting of the lines in a DOM, let's first understand what DOM is? So, DOM is like an API for HTML and XML documents. This logic is enough to understand that DOM is an important concept for web developers. The DOM gives a programming interface for HTML and XML documents that gives programmers control over a webpage's structure, look, and content. So, in this article we will see how to count the number of lines in the given text on the web page in a DOM element. Method 1: Using the scrollHeight Property Making ... Read More

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

Saurabh Anand
Updated on 21-Feb-2023 17:11:52

22K+ 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 JavaScript includes a "Date" class that allows us to work with dates and timings. The Date class includes various methods for working with dates and times, including − Date() - returns the current ... Read More

Advertisements