Found 6710 Articles for Javascript

How to find the href attribute of a link in a document in JavaScript?

Lokesh Yadav
Updated on 08-Dec-2022 07:56:56

3K+ Views

In this following article we are going to learn how to find the href attribute of a link in a document in JavaScript. The DOM property in the JavaScript provides many properties like , , , , , . There are two ways we can represent the links in HTML DOM. The DOM object provides links property. The href attribute in the anchor tag specifies the URL. To get the href attribute, we need to find the anchor object reference. To get a better idea of this concept, let’s look into the syntax and usage of the href attribute of ... Read More

How to find the number of links in a document in JavaScript?

Lokesh Yadav
Updated on 08-Dec-2022 07:55:38

1K+ Views

In this article we are going to discuss how to find the number of links in a document in JavaScript. The DOM property in the JavaScript provides many properties like , , , , , . There are two ways through which we can represent the links in HTML DOM. The DOM object provides links property. The document.links property provides us a collection of and tags inside a document. The document.links property is similar to an array. We can access any property (like href, name, title) of the links using this property. To find the total number of ... Read More

How to get a particular anchor in a document in JavaScript?

Lokesh Yadav
Updated on 08-Dec-2022 07:54:19

2K+ Views

In this article we will learn how to get a particular anchor in a document in JavaScript. The Javascript anchor tags follow an array-like structure. When we try to display a particular anchor tag we have to use ,document.anchors.innerHTML method. This method works the same as array methods which are used to display a particular element. To get a better understanding let’s look into the usage and syntax of anchor tag in JavaScript. Syntax The syntax to get a particular anchor tag is shown below. document.anchors[i].innerHTML or document.getElementsByTagName(“a”)[i].innerHTML Example 1 The following is an example program to get a ... Read More

How to find a number of anchors in a document in JavaScript?

Lokesh Yadav
Updated on 08-Dec-2022 07:52:56

1K+ Views

This article discusses about how to find the number of anchors in a document in JavaScript. The anchor tag is a part of HTML DOM elements. The anchor property is a read only property that returns a list of anchor tags inside a document. The anchor object is represented as . There are two ways to get the length of the anchors object. One way is to use the anchors.length property that returns the number of anchor tags in a document. The other way is to use getElementByTagName method to access the anchor tag and use the length property. Both ... Read More

How to get the title and full URL of a document in JavaScript?

Lokesh Yadav
Updated on 08-Dec-2022 07:50:08

1K+ Views

In this article we will learn how to get the title and full URL of a document in JavaScript with the help of examples. The Javascript HTML DOM has provided some basic methods to access and manipulate the HTML data. To find the title and URL of a document, JavaScript has provided document.title and document.URL respectively. The document.title property − The document.title property returns the current title of the document. This property applies to HTML, SVG, XUL, and other documents. The syntax to get the title of the document is shown below. document.title The document.url property − The URL ... Read More

How to find the href and target attributes in a link in JavaScript?

Manisha Patil
Updated on 04-Aug-2022 10:28:09

7K+ Views

First, let us understand how attributes work in JavaScript. Any element's attributes can be changed with JavaScript. The attributes property stores them, and invoking it gives you direct access to them. If we target an element with a class, the class will also appear as an attribute, and we can actually utilize these attribute methods to change classes if we so choose. Now, keep in mind that while we have designated the properties and methods for classes, you can also utilize all of these characteristics to manipulate classes in any element if necessary. href attributes in JavaScript In the href ... Read More

How to know the browser language and browser platform in JavaScript?

Lokesh Yadav
Updated on 08-Dec-2022 07:48:23

695 Views

In this article we are going to discuss how to know the browser language and browser platform with the help of examples in JavaScript To know the various properties of the browser, the JavaScript provides Navigator object. The Navigator object has several properties, which include - connection, credentials, cookies, geolocation, language, platform, etc. We are concerned with Navigator.language and Navigator.platform to know the language and platform of the browser. Let us discuss about them in detail. Navigator.language The read-only Navigator.language property returns a string that represents the browser UI language. It returns a string that returns the language version. For ... Read More

What is the use of Higher-order functions in JavaScript?

Lokesh Yadav
Updated on 08-Dec-2022 07:47:19

1K+ Views

In this article we are going to discuss the use of Higher-order functions in JavaScript. A higher order function is simply, a function that accepts other functions as parameters and/or returns a function. To know about Higher-order functions, we should learn about call back functions. A call back function is a function that is passed to another function as an argument. With the help of call back functions, one function can call another function and the call back function runs only after other function has finished. Some of the higher-order functions are map, reduce and filter. In order to understand ... Read More

How to clone an object using spread operator in JavaScript?

Manisha Patil
Updated on 04-Aug-2022 11:55:49

2K+ Views

The spread operator, which was first introduced in ES6, is used to unpack the elements of an iterable like an array. Cloning and merging the array is simple thanks to the spread operator. The spread operator could not be used with objects when it was first introduced in ES6. The spread operator was eventually extended to objects in ES2018. You'll learn how to use the JavaScript object spread (...) to clone an object or merge two objects into one in this article. In areas where 0+ arguments are expected, the spread operator allows an iterable to extend. This is most ... Read More

What is the use of exec() regex method in JavaScript?

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

122 Views

exec()The exec() method is a regex method. It searches a string for a specified pattern and, unlike test() regex method, returns the found text as an object. If there are no matches it will give null as an output. Let's discuss it in detail.Example-1In the following example, a variable pattern "est" is checked through the exec() method. The exec() regex method, after scrutinizing the given pattern throughout the text, returned the pattern as an object.Live Demo var obj = /est/.exec("Tutorix is the best e-learning platform"); document.write( "The object is ... Read More

Advertisements