I'm looking for a similar solution for a similar problem. In my case I want to select the last dd
in a dd
group, so therefore any dd
that is followed by dt
or is the first child of the dl
(since, for whatever reason, this is allowed).
I also haven't found a pure CSS solution. I was toying around with multiple rules such that all that would remain would be (in your case) the "empty" dt
, but nothing all inclusive.
If I get that to work, I'll let you know. Otherwise, the solution that is selector-like (thus keeping any other selector syntax intact) is the jquery non-css :has()
selector. So in your case:
$("dt:not(:has(+dd))").addClass("empty_def");
$("dt:has(+dd)").addClass("non_empty_def");