I
I
Indus Indusovich2015-10-28 14:31:46
JavaScript
Indus Indusovich, 2015-10-28 14:31:46

What's my mistake?

Actually the code is jsfiddle.net/d69ne/16
I understand that the error is simple, you must probably set some condition so that the code does not interrupt each other. Tell me what's wrong?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
rakro, 2015-10-28
@rakro

Clicking on the .button will always work because you have all the elements wrapped in it. It is better to make the hidden class and add/remove it to nested elements through toggleClass. And remove all show hide

D
Dmitry Kovalsky, 2015-10-28
@dmitryKovalskiy

And what exactly should be? One text appears, another disappears. Without a task, it is impossible to understand what works correctly and what does not.

D
Dasha Tsiklauri, 2015-10-28
@dasha_programmist

1) maybe get rid of the nesting of internal elements in each other in the DOM, and store the tree in JS? and in the html markup everything is flat
2) keep the structure, but hang the click handlers on h2, thus change to:
$('.button h2')
$('.subcat h2')
$('.subcat2 h2')
, etc. d.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question