Aven Desta
Aven Desta

Reputation: 2443

cheerio select element with multiple class separated with space

I have this html and want to select only the div with class 'image-container landscape'.

<div class="image-container landscape">
        ...
</div>
...
<div class="image-container portrait">
        ...
</div>

Using $(element).find('.image-container') selects either one of the div, that comes first. But I only want the one with 'landscape'. I tried using $(element).find('.image-container landscape') but it doesn't work, maybe because it assumes landscape is a tag. How do I do this?

Upvotes: 4

Views: 6743

Answers (1)

pguardiario
pguardiario

Reputation: 54984

Yes, it would assume landscape was a tag. You want either:

[class="image-container landscape"]

or

.image-container.landscape

This is just CSS3 for the record, you can probably read the full specs in less than an hour.

Upvotes: 11

Related Questions