Removing a group of elements using CSS selectors

Have an offending group of HTML elements? This task will obliterate them in one fell swoop.

Getting ready

CSS Selectors are used in styling to grab specific elements. This makes them a great way to also identify and group elements of our HTML DOM. Remember, grab single elements by their ID attributes; those are always unique on a page.

How to do it...

Grab groups of elements by CSS selector, most frequently by class. In our example, we use both class and tag CSS syntax to group together elements that we will remove.

<script type="text/javascript" src="mootools-1.3.0.js"></script> </head> <body> <p class="remove"><span>The </span> Fox jumped over the lazy dog.</p> <p class="remove">Jack and Jill went ...

Get MooTools 1.3 Cookbook 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.