In this section we will learn that the createTFoot() method is and how to use it in JavaScript.
What is createTFoot() Method in JavaScript?
The JavaScript createTFoot() creates and adds a <tfoot> element to a table.
Note: if the target table already has a <tfoot> element, then calling this method on the table won’t create another footer! Instead, it will just return a reference from that <tfoot>.
Note: you can use the deleteTFoot() method to remove a <tfoot> element from a table.
Note: when creating a <tfoot> element, you must also add one or more rows to it as well. To do this, you can use the insertRow() method.
createTFoot() Method Syntax:
tableElement.createTFoot();
createTFoot() Method Parameter
The method does not take an argument.
createTFoot() Method Return Value
If the target table did not have a <tfoot> already, then calling this method will create a new <tfoot> and add it to the table. In such cases, the return value of the method will be a reference to the footer that is already created.
But if the target table already has a <tfoot>, then calling this method will return a reference from that <tfoot> element.
Example: using createTFoot() Method in JavaScript
See the Pen using createTFoot() Method in JavaScript by Omid Dehghan (@odchan1) on CodePen.