how to select a specific element if both have same classname
lets say I have these two buttons
then how do I select the button with the text restart, menu
I tried doing this
button with menu text is selecting but restart is not selecting
8 Replies
easiest would be to just give them IDs
you mean give different classnames two the different element
this thought also first came in my mind
We'd have to see more context for why or why not
:nth-child()
would we working... but yeah, having another way to select them would be ideal?ok
well, that works too, but you can do
and then
Just make sure that all your IDs are unique
sorry my bad I didn't show the full code
these two button have a div between them
also I did some changes in the css
and it worked
can you explain why this worked
is this have anything related to the div between the two button
nth-child looks at ALL the siblings within a parent, not only the ones that have the same class (or other selector). so in this case the navbutton is the fist and third child. the div in between is de second
in your case could also use the :first-child and :last-child selector (if there are no other elements after the second button.
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View