In today's world, we often use CSS modules or other methods to hide classes and IDs. However, there are times when we need to select elements using JS selectors, and that can be a bit tricky.
Let's take an example. If we look at the home screen of YouTube, we might want to select the "Subscription" sidebar button. It seems like we could use the text value "Subscription" with a method like
document.getElementByValue("Subscription")
. Do you think this is the right approach, or is there a better way to achieve this?
How can we effectively select elements using JS selectors?
https://i.sstatic.net/Qs20R.jpg
Here are some sources I found while researching: