Web developer can manipulate the DOM, by modifying object of the page. He/she can add or remove the element; add, modify, or remove an attribute; and so on.  For example the code:

C# 8.0 and .NET Core 3.0 – Modern Cross-Platform Development: Build applications with C#, .NET Core, Entity Framework Core, ASP.NET Core, and ML.NET using Visual Studio Code, 4th Edition
ASP.NET Core 3 and Angular 9: Full stack web development with .NET Core 3.1 and Angular 9, 3rd Edition
C# in Depth, 4th Edition

$(“#tree li:first > ul”).append($(“<li>”).html(“last node”));

retrieves the element to which the new element must be added. First the query gets the tree element; then it takes the first li children and goes to the ul direct child. After retrieving the treeview node,  Web developer uses the append method to add a DOM element. The append method accepts a parameter that contains a jQuery object containing one or more DOM elements. A new jQuery object is built with a li tag and is set the inner HTML coding to last node. Note: The <tag> syntax is special syntax that tells the $ method that although Web developer’s passing a string, he/she doesn’t need to issue a query; rather he/she’s just creating an object with this tag.

Web developer can follow the opposite approach: create the new object and append it to the treeview element. In this case he/she has to use appendTo method:

$(“<li>”).html(“last node”).appendTo($(“#tree li:first > ul”));

When Web developer has to remove the element he/she has to retrieve the element through a query and then invoke the remove method:

$(“#tree li:first > ul > li:last”).remove();