0

How does one select the class jdgm-paginate__page unless jdgm-paginate__next-page is also applied to the element?

<a class="jdgm-paginate__page " data-page="2">2</a> <a class="jdgm-paginate__page jdgm-paginate__next-page" data-page="2"></a>

Temani Afif
  • 245,468
  • 26
  • 309
  • 415
Joe Ainsworth
  • 571
  • 1
  • 6
  • 20
  • Possible duplicate of [Can I write a CSS selector selecting elements NOT having a certain class?](https://stackoverflow.com/questions/9110300/can-i-write-a-css-selector-selecting-elements-not-having-a-certain-class) – Sebastian Brosch Aug 17 '18 at 14:48

3 Answers3

3

Use the :not() pseudo-class:

.jdgm-paginate__page:not(.jdgm-paginate__next-page):not(.jdgm-paginate__last-page) {
  color: red;
}

a {
  display: block;
}
<a class="jdgm-paginate__page " data-page="2">select</a>
<a class="jdgm-paginate__page jdgm-paginate__next-page" data-page="2">don't select next</a>
<a class="jdgm-paginate__page jdgm-paginate__last-page" data-page="2">don't select last</a>
Ori Drori
  • 183,571
  • 29
  • 224
  • 209
1

You can use the CSS :not pseudo class. For example:

.jdgm-paginate__page {
  background: red;
}

This would make all elements with that class red regardless of additional classes.

.jdgm-paginate__page:not(.jdgm-paginate__next-page) {
  background: red;
}

All elements with class .jdgm-paginate__page but no with .jdgm-paginate__next-page will be red

0

Maybe not the best solution, but you can also use attribute selector to select your specific element in case you don't know what are the other classes:

[class="jdgm-paginate__page"] {
  color: red;
}

a {
  display: block;
}
<a class="jdgm-paginate__page" data-page="2">select</a>
<a class="jdgm-paginate__page jdgm-paginate__next-page" data-page="2">don't select next</a>
<a class="jdgm-paginate__page jdgm-paginate__last-page" data-page="2">don't select last</a>
Temani Afif
  • 245,468
  • 26
  • 309
  • 415