As can be done without being attached to id?

Good day!

Did the block is displayed if you click the link. But if more we have to do this design
$('#zurnalItem_1').click(function(){
$('#zurnalItemImg_1').stop(false, false).slideToggle('slow');
$('#zurnalItemImg_2').slideUp('slow');
$('#zurnalItemImg_3').slideUp('slow');
$('#zurnalItemImg_4').slideUp('slow');
$('#zurnalItemImg_5').slideUp('slow');
$('#zurnalItemImg_6').slideUp('slow');
$('#zurnalItemImg_7').slideUp('slow');
$('#zurnalItemImg_8').slideUp('slow');
$('#zurnalItemImg_9').slideUp('slow');
});

That is not very when a lot of them or when you don't know what will be the digit in the id. Is there any way to do that would be js itself defines what is clicked and show block with zurnalItemImg_ and one digit as the unit zurnalItem_
July 4th 19 at 22:54
2 answers
July 4th 19 at 22:56
Install each unit class, detektywi clicking on the block class and determines the id of the block after pressing.

For example, set all the class="pop"
Processed, and click this:
$('.pop').click(function() {
 $('#' + this.id).slideUp('slow');
});
Then rolls up the link where I ordered the class. And the unit does not appear. - Vivien.Stehr commented on July 4th 19 at 22:59
: I gave an example of a selector, not a ready solution - kiley_Gottli commented on July 4th 19 at 23:02
July 4th 19 at 22:58
All the links a common class and id of an image in a thread parameter type data-img

<a class="link_class" data-img="1" ........ $('.links_class').click(function(){ var id="$(this).attr('data-img');" $('#zurnalitemimg_'+id).stop(...........< code></a>
$('.links_class').click(function(){
var id =$(this).attr('data-img');
$('#zurnalItemImg_'+id).stop(false, false).slideToggle('slow');
});

If I write so it all works. But to do that would have been open were closed and the new but its place. Now if you open a new he below opens.
In the old this is answered $('#zurnalItemImg_9').slideUp('slow'); For hiding - Vivien.Stehr commented on July 4th 19 at 23:01
: anyone who offers the same General class, first the class name close all, then open the ID that you need - kiley_Gottli commented on July 4th 19 at 23:04
: type
$('.links_class').click(function(){
$('.zurnalItemImgs').slideUp('slow');
var id = $(this).attr('data-img');
$('#zurnalItemImg_'+id).stop(false, false).slideToggle('slow');
}); - Vivien.Stehr commented on July 4th 19 at 23:07
Yes, all prescribed (a hdata-img="6" class="links_class") - Narciso5 commented on July 4th 19 at 23:10
In js I tried so
('.links_class').click(function(){
var id =$(this).attr('data-img');
$('#zurnalItemImg_'+id).slideUp('slow');
$('#zurnalItemImg_'+id).stop(false, false).slideToggle('slow');
});

Care does not close the outdoor before that.

P. S Sorry js is still trying to master - Narciso5 commented on July 4th 19 at 23:13
: blocks too General class, write and close them by class name - Vivien.Stehr commented on July 4th 19 at 23:16
: Not working. Still not closed. - Vivien.Stehr commented on July 4th 19 at 23:19
:

(div class="zurnalItemImgs" id="urnalItemImg_1".................

(a class="link_class" data-img="1"........

$('.links_class').click(function(){
$('.zurnalItemImgs').slideUp('slow');
var id =$(this).attr('data-img');
$('#zurnalItemImg_'+id).stop(........... - Narciso5 commented on July 4th 19 at 23:22
(div class="previy_zurnal_wrap zurnalItemImgs" id="zurnalItemImg_8")

(a href="#" data-img="2" class="links_class")

$('.links_class').click(function(){
$('.zurnalItemImgs').slideUp('slow');
var id =$(this).attr('data-img');
$('#zurnalItemImg_'+id).stop(false, false).slideToggle('slow');
}); - Vivien.Stehr commented on July 4th 19 at 23:25
And it does not want. - Narciso5 commented on July 4th 19 at 23:28
must. Check that you have not. - Vivien.Stehr commented on July 4th 19 at 23:31
not working. Okay thank you very much! for the help. I will ship you. - Vivien.Stehr commented on July 4th 19 at 23:34
and once again, check where you have classes and ID - Narciso5 commented on July 4th 19 at 23:37
Everywhere like as you wrote
skrinshoter.ru/s/200916/Xy1Kzn?a
skrinshoter.ru/s/200916/pvqx1b?a - Vivien.Stehr commented on July 4th 19 at 23:40
: codepen.io/ilyap/pen/yaVrBv - Narciso5 commented on July 4th 19 at 23:43
Thank you very much for not sending such babesa I ) Now understand how to do that would only 1 items was visible initially and will be super. Thanks again!!! - Vivien.Stehr commented on July 4th 19 at 23:46

Find more questions by tags JavaScript