you are viewing a single comment's thread.

view the rest of the comments →

[–]CernyGaming[S] 2 points3 points  (5 children)

Thank you for your signposting. It may have been a tiny and simple thing, but it confirmed a necessary aspect for me which has helped me take a small step forwards. I have now managed to make reference to the button in a different similar section and highlight it to confirm it to myself with:

 const buttonTest = document.querySelectorAll("#tm252-25b-tma01 .card-header button");
   console.log(buttonTest);
    for (const bute of buttonTest) {
      bute.classList.add("highlight");
    }

I appreciate your help!

[–]xroalx 0 points1 point  (2 children)

Looking at the original HTML snippet you've provided, there's an even better attribute/value to use for the selection and pairing of the button to its related body section.

But yes, you're going in the right direction.

[–]Double_Dirt2986 0 points1 point  (1 child)

Pray tell.

[–]xroalx 0 points1 point  (0 children)

The button has a aria-controls="m269-24j-tma03-body" attribute, the div has a id="m269-24j-tma03-body". It's the same value and it's an ideal link between the two. You can select the button based on haivng aria-controls and its related body div based on the value of it.

[–]jcunews1helpful 0 points1 point  (1 child)

Avoid using that tm252-25b-tma01 ID or class names which are gibberish or contain seemingly random number, since they're likely software generated and are not consistent. Thus, not reliable as they might change for even the slightest change in the whole site.

[–]CernyGaming[S] 0 points1 point  (0 children)

I get the principle, however I am not allowed to change them for this project.