Book Image

Learning Dart, Second Edition - Second Edition

By : Ivo Balbaert
Book Image

Learning Dart, Second Edition - Second Edition

By: Ivo Balbaert

Overview of this book

Table of Contents (18 chapters)
Learning Dart Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Creating and removing elements


The structure of a web page is represented as a tree of nodes in the DOM. A web page can start its life with an initial DOM tree, marked up in its HTML file, and the tree can be changed using the code; or it can start off with an empty tree, which is then entirely created using the code in the app: every element is created through a constructor and its properties are set in the code. Elements are subclasses of Node; they take up a rectangular space on the web page (with a width and height). They have, at most, one parent element in which they are enclosed and can contain a list of elements—their children (you can check this with the hasChildNodes()function that returns a bool function). Furthermore, they can receive events. Elements must first be created before they can be added to the list of a parent element. Elements can also be removed from a node. When elements are added or removed, the DOM tree changes and the browser has to re-render the web page.

An...