Open In App

D3.js | d3.selectAll() Function

Last Updated : 18 Jul, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report

The d3.selectAll() function in D3.js is used to select all the element that matches the specified selector string.

Syntax:

d3.selectAll("element")

Parameters: This function accepts single parameter HTML tag as a parameter.

Return Value: This function returns the selected elements.

Below programs illustrate the d3.selectAll() function in D3.js:

Example 1:




<!DOCTYPE html>
<html>
  
<head>
    <title>
        D3.js | d3.selectAll() Function
    </title>
      
</head>
  
<body>
    <div>Geeks</div>
          
    <div>GeeksforGeeks</div>
          
    <script>
          
        // Calling the selectAll() function
        d3.selectAll("div").text();
    </script>
</body>
  
</html>                    


Output:

Geeks
GeeksforGeeks

Example 2:




<!DOCTYPE html>
<html>
  
<head>
    <title>
        D3.js | d3.selectAll() Function
    </title>
      
</head>
  
<body>
    <p>GeeksforGeeks</p>
          
    <p>A computer science portal for geeks</p>
      
    <p>d3.selectAll() function</p>
          
    <script>
          
        // Calling the selectAll() function
        d3.selectAll("p").text();
    </script>
</body>
  
</html>                    


Output:

GeeksforGeeks
A computer science portal for geeks
d3.selectAll() function

Reference: https://devdocs.io/d3~5/d3-selection#selectAll



Next Article

Similar Reads