Guys, this is a simple tip to get the selector very easily. The browser inspection copy function.
Well, sometimes that functionality is very useful if you are handling a lot of HTML injections from these new javascript frameworks. Is expected that you do not need this, but someday, maybe this helps you save a little time.
Just inspect the code, use the right-click in your tag element and select the copy option on the menu, and then choose copy selector or copy js path. (Same as the image example)
Ex:
document.querySelector("#root > div > div.rightPanel > div.presentMe > div.name")
NOTE.1: Most of the time you should reduce the size of the selector. (Depends on the situation, analyze pls)
Ex:
document.querySelector("rightPanel div.name")
That is it :D! You got the selector.
Thanks, Vinicius Tartari for sharing this knowledge with me :)
Top comments (0)