Removing Things

Removing an element from the document is quite Darty.

dom/removing.dart
 
document.
 
query(​'#content'​).
 
query(​'#gallery'​).
 
remove();

This would find the element with the ID of "content"; then, inside that, it would find the "gallery" element and remove it from the page. If the page began:

 
<body>
 
<div​ id=​"content"​​>
 
<div​ id=​"gallery"​​/>
 
<p​ class=​"instructions"​​>​...​</p>
 
</div>
 
</body>

then the result of the previous remove would be as follows:

 
<body>
 
<div​ id=​"content"​​>
 
<p​ class=​"instructions"​​>​...​</p>
 
</div>
 
</body>

Not being required to walk up to an element’s parent to remove the element, as we have to do in JavaScript, is a nice win.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.172.130