T
T
timtimIT2015-10-24 21:52:39
JavaScript
timtimIT, 2015-10-24 21:52:39

How to specify that the div that comes immediately after the button that was clicked is unfolded, and not all divs with this class?

Hello.

There is a code.

$(".button-read_more").click(function(e){
  e.preventDefault();
  $("div.b-room-full-info").slideToggle("slow");	
});


How to specify that the div that comes immediately after the button that was clicked unfolds?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Sofronov, 2015-10-24
@maxsof

$(".button-read_more").click(function(e){
    e.preventDefault();
    $(this).next().slideToggle("slow");	
});

I
Ilyusha Prokopiev, 2015-10-25
@iliapro

Instead $("div.b-room-full-info"), use $(this)- refers directly to the element that called the function. Or use id instead of class. Essentially the same, but is unique, unlike a class. Then the code will be like this:$("#id_of_your_div")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question