Found 6710 Articles for Javascript

innerHTML vs innerText in JavaScript.

AmitDiwan
Updated on 16-Jul-2020 13:55:22

1K+ Views

innerHTML − The innerHTML property returns the text, including all spacing and inner element tags. It preserves the formatting of the text and all the extra tags like , etc.innerText − The innerText property returns just the text, removing the spacing and the inner element tags.Following is the code for innerHTML and innerText in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result,    .sample {       font-size: 18px;       font-weight: 500;       color: red;   ... Read More

Undeclared vs Undefined? In JavaScript

AmitDiwan
Updated on 16-Jul-2020 13:52:48

1K+ Views

Undeclared − It occurs when a variable which hasn’t been declared using var, let or const is being tried to access.Undefined − It occurs when a variable has been declared using var, let or const but isn’t given a value.Following is the code for undeclared and undefined in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 18px;       font-weight: 500;       color: blueviolet;    } Undeclared vs Undefined ... Read More

Validating a file size in JavaScript while uploading

AmitDiwan
Updated on 16-Jul-2020 13:51:30

977 Views

Following is the code for validating a file size in JavaScript while uploading −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 18px;       font-weight: 500;       color: blueviolet;    } Validating a file size while uploading Upload a file using the above file input type    let BtnEle = document.querySelector(".Btn");    let resEle = document.querySelector(".result");    let fileEle = document.querySelector(".file");    function validateFile() {       if ... Read More

Function returning another function in JavaScript

AmitDiwan
Updated on 16-Aug-2023 15:37:40

681 Views

In JavaScript, functions can be assigned to any variables, they can be passed as arguments to other functions, and can even be returned from other functions. This behavior of functions allow us create HOCs in javascript, which are functions that return other functions. These higher−order functions can be used in various applications like callback functions, function memoization, or transformation, etc. In this article, we will learn functions returning another function, aka higher−order functions in javascript, and how we use them to implement certain javascript features like callbacks, array/object filtering and transformations, etc. Let’s look at some of the examples to ... Read More

How to add delay in a loop in JavaScript?

AmitDiwan
Updated on 16-Aug-2023 15:20:32

5K+ Views

Loops are used in JavaScript to repeat actions or iterate over a piece of data. With the aid of various techniques, we can add a delay between each iteration of the loop in order to regulate the speed of execution or produce particular temporal effects. This article will teach you how to include a delay in a java script loop and how to use it to delay the execution of a specific piece of code that is running inside one. Let’s look at some of the examples to understand the concept better − Example 1 - Using setTimeout() In the ... Read More

Program to check/uncheck checkboxes using JavaScript

AmitDiwan
Updated on 16-Aug-2023 15:14:47

527 Views

We will learn how to check or uncheck checkboxes in javascript in this article, and how we can use it to allow users to make multiple selections on the web page Checboxes are one of the most used HTML elements in forms and user interfaces that allow users to pick numerous options. In JavaScript, we can dynamically check or uncheck checkboxes based on certain conditions or user interactions. Let’s look at some of the examples to understand the concept better − Example 1 In this example, we will − We will create 3 different checkboxes, a checkAll() and ... Read More

Higher-Order Arrow Functions in JavaScript.

AmitDiwan
Updated on 16-Jul-2020 13:40:12

373 Views

JavaScript treats functions as objects and allow us to pass functions as parameter to another function and even return functions from other functions. In JavaScript, the functions are first class functions i.e. we can store them in variable, objects and array. The higher order arrow functions can take function, return them or do both.Following is the code for higher order arrow functions in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result,    .sample {       font-size: 18px;       ... Read More

JavaScript program to retrieve clients IP address

Shriansh Kumar
Updated on 08-Oct-2024 17:20:26

1K+ Views

Internet Protocol address, in short, IP address, is a unique address represented by a string of numbers that identifies a device on the internet or a local network. In JavaScript, we can retrieve a client's IP addresses using a 3rd parties API services such as ipify or ipapi. We can then further use this information to track user locations, personalize content based on the location, or implement security measures. Using "ipify" API To obtain the client's IP address, we will use a third−party API service (https://www.ipify.org/). We'll send a GET call to the "ipify" API using the $.getJSON() function to ... Read More

Disabling arrow key in text area using JavaScript.

AmitDiwan
Updated on 16-Jul-2020 13:35:40

321 Views

Following is the code for disabling arrow key in text area in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-weight: 500;       font-size: 18px;       color: blueviolet;    } Disabling arrow keys in a text area Hello world this is some sample text inside the text area element Disable arrows Click on the above button to disable scrolling using arrows in the above textArea    let ... Read More

Setting full screen iframe in JavaScript?

AmitDiwan
Updated on 16-Jul-2020 13:33:03

2K+ Views

Following is the code for setting full screen iframe in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-weight: 500;       font-size: 18px;       color: blueviolet;    }    .fullScreen {       width: 100vw;       height: 100vh;    } Setting full screen iframe Fullscreen Click on the above button to make the iframe go fullscreen    let BtnEle = document.querySelector(".Btn");    let frameEle = document.querySelector(".frame");    BtnEle.addEventListener("click", () => {       frameEle.className = "fullScreen";    }); OutputOn clicking the ‘Fullscreen’ button −

Advertisements