D3.js html() Function Last Updated : 31 Aug, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The d3.html() function in d3.js is used to fetch and read the file of type HTML. It fetches the file as text first then parses the file as HTML. Syntax: d3.html(input[, init]); Parameters: This function accepts two parameters as mentioned above and described below: input: This parameter is the address of the input file. init: This parameter takes a function. Note: Please create a file named sample.html before going through the below given example. Example 1: Filename: sample.html html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content= "width=device-width, initial-scale=1.0"> </head> <body> <p>I am a p tag</p> <script> alert("This is from d3.html() function") </script> </body> </html> Filename: index.html html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" path1tent= "width=device-width, initial-scale=1.0"/> <script src="https://d3js.org/d3.v4.min.js"> </script> </head> <body> <script> d3.html("sample.html", function (d) { console.log(d); }); </script> </body> </html> Output: Example 2: Filename: sample.html html <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content= "width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <h3>D3.js | d3.html() Function</h3> <p>I am a p tag</p> </body> </html> Filename: index.html html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" path1tent= "width=device-width,initial-scale=1.0"/> </head> <body> <script src="https://d3js.org/d3.v4.min.js"> </script> <script> d3.html("sample.html", function (d) { d = [].map.call(d.querySelectorAll("p"), (p) => { var h3 = d.querySelector("h3"); document.write(`<h3>${h3.textContent}</h3>`); document.write(`<p>${p.textContent}</p>`); }) }); </script> </body> </html> Output: Comment More infoAdvertise with us Next Article D3.js dsv() Function T tarun007 Follow Improve Article Tags : JavaScript Web Technologies D3.js Similar Reads D3.js image() Function The d3.image() function in D3.js is a part of the request API that is used to fetch the images from any given image URL. If init is also given in the function then it sets any additional properties on the image before loading the image. Syntax: d3.image(input[, init]); Parameters: This function acce 1 min read D3.js dsv() Function The d3.dsv() function in D3.js is a part of the request API that returns a request for the file of type DSV. The mime type is text/DSV. Syntax:d3.dsv(delimiter, inputfile, function);Parameters: This function accepts three parameters as mentioned above and described below:delimiter: It is the delimit 1 min read D3.js style() Function The d3.style() function is used to style the specified node(attribute) with the specified name(Value). In this, if the node has an inline style with the specified name, its value is returned and if the node has not an inline style, the calculated value is returned.Syntax: d3.style(node, name)Paramet 1 min read D3.js creator() Function The d3.creator() function is used to return a function that creates an element whose name is given as a parameter in the function. Syntax: d3.creator( name ); Parameters: This function accepts single parameter as mentioned above and described below: name: It is the name of the container or HTML tag 2 min read D3.js matcher() Function The d3.matcher() function in d3.js is used to return a function which either returns true or false depending on the element. If element matches than it returns true else it returns false. Syntax: d3.matcher(selector); Parameters: The above-given function takes only one parameter which is given above 2 min read D3.js timeout() Function The d3.timeout() function in D3.js is used to automatically stop the function or the timer after a particular interval of time. It works same as setTimeOut() function in JavaScript. Syntax: d3.timeout(callback, delay); Parameters: This function accepts two parameters as mentioned above and described 2 min read Like