Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 367
Aven Desta Avatar asked Oct 20 '25 14:10

Aven Desta


1 Answers

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.

like image 144
pguardiario Avatar answered Oct 22 '25 04:10

pguardiario