On Monday, July 10, 2023 at 9:12:05 PM UTC-5, luserdroog wrote:
> > Just style it as appropriate
> Well, dang. I wish I'd noticed that earlier. Thanks. That does 90% of what
> I wanted. Ultimately, I found the extra flexibility very useful. Being able to
> toggle the "more" and "less" classes separately on the contents means
> I can pop up an important control into the abbreviated state by just
> adding "less" to it. I suppose I could accomplish similar with some js
> gymnastics upon a <details />.
>
> Anyway, good to know. I like mine better.
Well, the open state of <details /> can be styled with: details[open].
The JavaScript event is simply:
details.addEventListener("toggle", (event) => {
if (details.open) {
/* the element was toggled open */
} else {
/* the element was toggled closed */
}
});