Found 9053 Articles for Front End Technology

How to find the text visible on the button with JavaScript?

Abhishek
Updated on 31-Oct-2022 08:04:54

7K+ Views

In this tutorial, we will discuss different approaches to find the text visible on the button with JavaScript. The text on a button shows what will happen if you click the button. To extract the text on the button, JavaScript provides us with the following two properties. Using the innerHTML Property Using the innerText Property Let us discuss both of the above properties in detail. Using the innerHTML Property The innerHTML property not only allows us to get the text inside any tag but also allows us to set the text to any tag. This property also allows ... Read More

How to find the id of the form a button belongs to in JavaScript?

Abhishek
Updated on 31-Oct-2022 07:55:45

4K+ Views

In this tutorial, we will learn how we can find the id of the form element to which a button belongs using JavaScript. In HTML, we can use button tag in two ways with form tag, where it can be used to perform some activity in the form when it is clicked, as listed below − Button is inside the FORM tag Button is outside the FORM tag No matter where the button is located, whether it is inside or outside, we can find the ID of the form tag to which the button belongs using JavaScript. Let ... Read More

How to convert String to Number in JavaScript?

Shubham Vora
Updated on 10-Aug-2022 12:31:22

527 Views

In this tutorial, we will learn to convert the string to a number in JavaScript. The string and number are the data types of JavaScript. Programmers frequently need to change the data type of the variables, and we will learn the same. Various approaches are explained in this tutorial to convert the string to a number. Using the Number() Constructor Using the parseFloat() Method Using the Unary (+) Operator Using the Number() Constructor In the first approach to convert the string to a number using JavaScript, we will use the Number() constructor. It is a constructor of the ... Read More

How to use JavaScript to replace the content of a document with JavaScript?

Abhishek
Updated on 25-Nov-2022 07:35:35

2K+ Views

In this tutorial, we will learn how we can use JavaScript to replace the content of a HTML document. In JavaScript, we can change the content of HTML document with a combination of following methods − open − The open method is used to open a new document which takes two arguments as text/html and replace, where first argument will define the type of new document to be formed and the later one will replace all the adds history on the previous page and help to open new document with ease. document.open("text/html", "replace"); write − After creating ... Read More

How to convert Number to String in JavaScript?

Shubham Vora
Updated on 10-Aug-2022 12:29:28

3K+ Views

This tutorial will teach us to convert the number to string in JavaScript. Changing the type of variable is called the type conversion of a variable. While coding, the programmer needs to deal with the different data types and might need to convert the variable's data type. Every programming language has different methods to convert one variable from one data type to another data type, and JavaScript also has some methods, which are explained below. Using the toString() Method Concatenating with an empty String Using the string() Constructor Using the toString() Method In JavaScript, the toString() method is ... Read More

How to show the full URL of a document with JavaScript?

Abhishek Kumar
Updated on 21-Sep-2022 07:46:36

1K+ Views

We use the URL property of the document object to show the full URL of a document with JavaScript. The document object, part of the DOM, corresponds to the current web page that the browser has loaded. It Contains all the information about the condition of the browser as well as the web page. It can be visualized as a hierarchy that is obtained after rendering the HTML structure of the web page. URL stands for Uniform Resource Locator. It contains the address of a resource on the internet. A Typical URL looks something like this− http://www.example.com/index.html It is ... Read More

How to show the date and time the document was last modified with JavaScript?

Abhishek Kumar
Updated on 21-Sep-2022 07:38:53

4K+ Views

We use the lastModified property of the document object to show the date and time the document was last modified with JavaScript. This command will provide the exact date and time of modification. The document object, part of the DOM, renders the whole HTML as a hierarchy of objects and their properties as well as stores different attributes of the webpage. document.lastModified It is a read-only property of the document object that returns a string containing the date and time, the document was last modified. The format looks something this: 07/29/2019 15:19:41 Note − The lastModified property is useful ... Read More

How to convert Number to Boolean in JavaScript?

Shubham Vora
Updated on 10-Aug-2022 12:18:29

2K+ Views

This tutorial will teach us to convert a number to a Boolean in JavaScript. The variable of Boolean data type can contain only two values, true and false. When we convert the variables of any other data type to Boolean, it returns true for all non-falsy values and false for all falsy values. Let’s understand the falsy values. The JavaScript contains 6+ falsy values, and some of them are as below. Null 0 NaN False Undefined ‘ ’ From the above falsy values, we can say that for 0, we will get the false Boolean value and for ... Read More

How to show name/value pairs of cookies in a document with JavaScript?

Abhishek Kumar
Updated on 21-Sep-2022 07:34:32

608 Views

We use the cookie property of the document object to show the name/value pairs of cookies in a document with JavaScript. The document object, part of the DOM, corresponds to the current web page that the browser has loaded. It Contains all the information about the condition of the browser as well as the web page. A server serves requests when a connection is set up and forgets everything about the user as soon as the connection is closed. This posed a nasty problem of bad user experience to the community. A cookie, resolves this problem by storing small but ... Read More

How to show the domain name of the server that loaded the document with JavaScript?

Abhishek Kumar
Updated on 21-Sep-2022 07:40:55

2K+ Views

We use the window.location.hostname property of the document object to show the domain name of the server that loaded the document using JavaScript. The document object, part of the DOM, corresponds to the current web page that the browser has loaded. It Contains all the information about the condition of the browser as well as the web page. Every resource or computer that is available on the internet has an address that is either IPV4 (192.88.99.255) or IPV6 (2001:db8:3333:4444:5555:6666:7777:8888). These addresses are good for computers but not for us. domain name system is a layer of abstraction over that organization ... Read More

Advertisements