Hello. Yes, I read that you can not use the same id. But I will explain the essence of my task.
I have generated 10, 20, 30 blocks with the same id (can be done with the class). I want that when I click on the button next to it, the necessary block will open. In my case, opens only the first. And if you write the same thing through class, then everything opens at once. How to do what would choose the block that I need.? Below is the code
HTML
<div class="shop_info">Показать</div> <div class="show_shop_info">Cдесь информация которая должна показываться</div> <div class="shop_info">Показать</div> <div class="show_shop_info">Cдесь информация которая должна показываться1</div> <div class="shop_info">Показать</div> <div class="show_shop_info">Cдесь информация которая должна показываться2</div> Jquery
$(document).ready(function () { var i=0; $('.shop_info').click(function() { if (i==0) { $('.show_shop_info').slideToggle('slow'); $('.shop_info').text('Спрятать'); i=1; } else { if (i==1) { $('.show_shop_info').slideToggle('slow'); $('.shop_info').text('Показать'); i=0; } } }); });
this. This is the raw element and to get a jQuery object you need to create it: $ ('. Shop_info'). On ('click', function () {var $ this = $ (this); $ this.text ('Hide '); $ this.next ('. show_shop_info '). slideToggle (' slow ');}); - etki