Good afternoon, you need to implement drop-down blocks in the layout (I immediately speak in js / jquery I understand at the beginner level), there is a block with a photo of a short info and a link (down arrow) when you click on the arrow the block will increase and reveal even more information. I thought to implement all this by adding a class with increased height by clicking on the arrow. In this way:

$(".select").click(function(e) { e.preventDefault(); $(".select-element").toggleClass("add-height"); }); 

But there was a bug that the class with height is applied to all elements and it turns out that they all go. We need another embodiment of the jquery function. Prompt possible solutions.

    1 answer 1

    If the .select-element block is nested in .select , then you should try using this :

     $(".select").click(function(e) { e.preventDefault(); // this для указания Π½Π° Π½Π°ΠΆΠ°Ρ‚Ρ‹ΠΉ элСмСнт // closest для поиска блиТайшСго родитСля $(this).closest(".select-element").toggleClass("add-height"); }); 
    • Everything is different there, the "select-element" block is a wrapper and "select" is a button inside this wrapper (it turns out that when you click on a button, a class is added to the wrapper, which increases its height), and this is not the first experience using this and it is why He does not want to work with him, maybe something is wrong with the logic? - Constantine Shibaev
    • @ConstantineShibaev corrected the answer - lexxl
    • Thank you so much, very much helped out. Already wanted to do on the basis of an accordion without js. - Constantine Shibaev