Javascript Articles

Page 124 of 534

How to format a number with two decimals in JavaScript?

Kumar Ishan
Kumar Ishan
Updated on 31-Oct-2023 102K+ Views

This tutorial will teach us how to format a number with two decimals using JavaScript. Formatting a number means rounding the number up to a specified decimal place. In JavaScript, we can apply many methods to perform the formatting. Some of them are listed as follows − The toFixed() Method Math.round() Method Math.floor() Method Math.ceil() Method The toFixed() Method The toFixed() method formats a number with a specific number of digits to the right of the decimal. it returns a string representation of the number that does not use exponential notation and has the exact number of digits after ...

Read More

How to Create and Save text file in JavaScript?

Shubham Vora
Shubham Vora
Updated on 31-Oct-2023 117K+ Views

In this tutorial, we will learn to create and save the text file in JavaScript. Sometimes, developers need to get texts or content from the user and allow users to store content in a text file and allow the file to download to the local computer. Many JavaScript libraries are available to achieve our goal, but we have used the best two libraries in this tutorial to create and save the text file. Create a text file using custom text and save it to a local computer We will use normal JavaScript operations to create and save the text file ...

Read More

How to delay a JavaScript function call using JavaScript?

Prince Varshney
Prince Varshney
Updated on 31-Oct-2023 97K+ Views

In this tutorial, we are going to learn how can we delay a function in JavaScript. Whenever we want to call a function after a specified amount of time than we use the delay function in JavaScript. To provide delay in JavaScript function we use a global window object named as setTimeout(). This function allows us to provide a specific delay before executing a function. Let’s deep down into some of the functionalities, syntax and many other things of setTimeout() function. The setTimeout() method mainly require two one is the function which we need to execute with some delay and ...

Read More

How to count JavaScript array objects?

Shubham Vora
Shubham Vora
Updated on 31-Oct-2023 26K+ Views

In this tutorial, we will learn to count JavaScript array objects. The array is the data structure containing the strings, numbers, objects, etc., in JavaScript. The object is the one kind of entity that contains properties and methods related to it. We can access the object's properties and invoke the object method using the object's references. Generally, To find the array length, we can use the array.length() method and it returns the total number of elements that the array includes. But what if we need to count only object elements? Here, this tutorial has various approaches to counting the total ...

Read More

How to clear cache memory using JavaScript?

Rushi Javiya
Rushi Javiya
Updated on 31-Oct-2023 36K+ Views

Cache memory, often known as cache, is a different memory system in a computer that stores frequently used data and instructions for a short period. While loading a website, the browser we are using will automatically cache some resources, such as images, scripts, and stylesheets, to be utilized again when the page is reloaded. This can shorten the time it takes for a website to load not only that but also it helps to lower the amount of data that has to be sent over the network. But this cache memory stored by the browser also has some disadvantages. If ...

Read More

Auto Grow a Textarea with JavaScript in CSS

AmitDiwan
AmitDiwan
Updated on 27-Oct-2023 491 Views

Using JavaScript, we can set our TextArea element to automatically grow with its content. The following examples illustrate how we can achieve the above scenario. Let us say the following is our TextArea before adding content − The following is the TextArea after adding content − The following is the same TextArea that auto grows itself after adding more content − Auto Grow a Textarea Example Let us see how to auto grow a textarea − * { ...

Read More

How to remove event handlers in JavaScript?

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 25-Oct-2023 30K+ Views

An event is defined as a change in an object's state. There are a number of events in HTML that show when a user or browser performs a certain action. JavaScript responds to these events when JavaScript code is embedded in HTML and allows execution. The process of responding to events is known as event handling. As a result, JavaScript uses event handlers to handle HTML events. In this article, we are going to discuss how to remove event handlers in JavaScript. Here, we use the removeEventListener() method to remove an event handler from an element in JavaScript. Using the ...

Read More

How to find the value of a button with JavaScript?

Abhishek
Abhishek
Updated on 21-Oct-2023 32K+ Views

In this tutorial, we will learn how we can find the value of a button with JavaScript. Sometimes, we need to use the button tag inside the form tag, where we assign a particularly unique value to each associated with the element using the value attribute. Which later helps the developer to uniquely identify the elements while working with them in the back end. JavaScript provides us with the value property to get the value passed inside the value attribute Let us discuss the value property in detail. Button value Property The button value property is used to get ...

Read More

How to find whether all element contains same class or not?

Aman Gupta
Aman Gupta
Updated on 13-Oct-2023 571 Views

Overview A class in any element defines the type of the data contained in an element. A same class name can be taken by another tag or element also. There is no such property for the class attribute that the class name should be unique. To find whether all the elements contain the same classes or not, can be achieved with the help of HTML, CSS and JavaScript. The HTML provides the layout of the page and the layout for the elements for the same classes and the JavaScript will provide the functionality to check whether all the elements contain ...

Read More

How to find width of a div using vanilla JavaScript?

Aman Gupta
Aman Gupta
Updated on 13-Oct-2023 2K+ Views

Overview A vanilla JavaScript is a framework of JavaScript, it provides mainly two different methods to find the width of a div using the "offsetWidth" and "clientWidth". Both methods have the ability to find the width of any element on a web page. In this vanilla JavaScript refers to the methods of the JavaScript that are predefined for the developers. It provides cross-platform compatibility. Syntax The Syntax to find the width of the div is given below. These two methods are used to calculate the width of the div. elementHTML.offsetWidth elementHTML.clientWidth elementHTML − It is the div ...

Read More
Showing 1231–1240 of 5,339 articles
« Prev 1 122 123 124 125 126 534 Next »
Advertisements