Web Development Articles

Page 361 of 801

How to get the number of forms in a document with JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 1K+ Views

In this tutorial, we will learn how to get the number of forms in a document using JavaScript. Since different methods are used to create forms in an HTML document, it might get tricky to get the number of forms present. However, you can use some methods to count the forms created without the form tag. Using the length Property The most widely accepted method to create forms in HTML documents is using the tag. Some websites also use tags to create forms in the document. Hence, we will discuss the method to get the number ...

Read More

How to find the name of the first form in a document with JavaScript?

Abhishek
Abhishek
Updated on 15-Mar-2026 1K+ Views

In this tutorial, we will learn how to find the name of the first form in an HTML document. Sometimes, we use more than one form tags in the HTML document for different purposes. At that time, we can face difficulties in finding the specific element to add some more properties to it. In such conditions, we can use the forms property of the "document" interface to access all the elements present in the document individually as well as collectively. Document.forms Property As we discussed above, the forms property is used to access all the forms ...

Read More

How to find the number of anchors with JavaScript?

Abhishek
Abhishek
Updated on 15-Mar-2026 347 Views

In this tutorial, we will learn how to count the number of anchor elements ( tags) in an HTML document using JavaScript. The document.anchors property provides a way to access all anchors with a name attribute in the document. Note: The document.anchors property is deprecated and only counts anchors with a name attribute. For modern development, use document.querySelectorAll('a') instead. Using document.anchors (Deprecated) The document.anchors property returns an HTMLCollection containing all anchor elements that have a name attribute. You can use the length property to get the count. Syntax let anchors = document.anchors; let numberOfAnchors ...

Read More

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

Abhishek Kumar
Abhishek Kumar
Updated on 15-Mar-2026 955 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 ...

Read More

How to convert Number to Boolean in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 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. JavaScript contains 6+ falsy values, and some of them are as below. Null 0 NaN False Undefined ' ' (empty string) ...

Read More

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

Abhishek Kumar
Abhishek Kumar
Updated on 15-Mar-2026 2K+ 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. 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 The Document Object Model of JavaScript acts as a layer of abstraction on the HTML page, creating ...

Read More

How to convert Number to String in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 4K+ 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 ...

Read More

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

Abhishek
Abhishek
Updated on 15-Mar-2026 3K+ Views

In this tutorial, we will learn how to use JavaScript to replace the entire content of an HTML document. JavaScript provides three document methods that work together to achieve this: open(), write(), and close(). The Three Methods document.open() − Opens a new document stream for writing. It takes two optional parameters: the MIME type (typically "text/html") and "replace" to replace the current document's history entry. document.write() − Writes content to the document stream. ...

Read More

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

Abhishek
Abhishek
Updated on 15-Mar-2026 5K+ 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 ...

Read More

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

Abhishek
Abhishek
Updated on 15-Mar-2026 10K+ 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 ...

Read More
Showing 3601–3610 of 8,010 articles
« Prev 1 359 360 361 362 363 801 Next »
Advertisements