M
M
Maxymus19962018-03-20 15:15:37
JavaScript
Maxymus1996, 2018-03-20 15:15:37

How to match ordinal indexes of elements in jQuery?

It is necessary to make it so that when you click on the button, a block is shown, and the rest are hidden. I'm trying to match the ordinal index of the button and the block, but only the first one works - 0 is equal to 0, and then the ordinal number of the button increases, and the block has a constant -1 (displayed to the console). How to solve the problem?
Example

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2018-03-20
@Maxymus1996

A page cannot have multiple elements with the same id, this is invalid. That's why your code only finds the first one, the rest are simply ignored. Replace id with class at least
Example

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question