Get attribute and class not active in Html

Before clicking the HTML tag,

<div id="sidebar">
  <a data-bs-target="#dashboards" data-bs-toggle="collapse" class="sidebar-link collapse" aria-expanded="true">Html Attribute</a>
</div>

After clicking the HTML tag,

<div id="sidebar">
  <a data-bs-target="#dashboards" data-bs-toggle="collapse" class="sidebar-link" aria-expanded="true">Html Attribute</a>
</div>

In CSS style get attribute and find collaspe class exist or not,

#sidebar [data-bs-toggle=collapse]:not(.collapsed) {
  // do something what you wnat
}