Updating Elements
We have already discussed adding and removing elements from a parent element. Aside from those actions, the most common manipulation is adding and removing CSS classes on an element. The following would remove the subdued class from the <blockquote> tag and add the highlighted class to it:
dom/updating.dart | |
| document. |
| query('blockquote'). |
| classes. |
| remove('subdued'); |
| |
| document. |
| query('blockquote'). |
| classes. |
| add('highlighted'); |
Here, we again see the difference between Dart’s set-based approach to classes and jQuery’s chainable approach. In jQuery, removing and adding classes could be accomplished in a single statement with several chains. In Dart (for now) we are forced to use two separate statements. Actually, ...
Get Dart 1 for Everyone now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.