Good day. While I was not showered with slippers, which I cannot add by clicking on a button on a class block, I hasten to notice what I can do. I have a different situation at the moment. There is a block with an unlimited number of children, the number I get by pressing a button, like this:
$('.range__read-more--link').click(function () { var slide = $('.range__slider__item--wrapper').children(); for (var i = 0; i < slide.length; i++) { console.log(slide[i]); } }); One click on the button should be added to one of the child elements each time a class. But with this I had a difficulty, and I ask for your help. If I specify
$(slide[i]).addClass('active'); So I add this class to all child blocks.
<section class="range"> <div class="slider range__slider"> <div class="range__slider__item--wrapper"> <div class="range__slider__item"> <div class="range__slider__img"><img src="img/production-items-1.png"></div> <div class="range__slider__info mCustomScrollbar"> <div class="range__slider__info__title">Идейные соображения высшего порядка, а также укрепление. </div> <p class="range__slider__info__description">Номенклатура конвейерных лент Nitta по-настоящему широкая</p></div> </div> </div> <div class="range__slider__item--wrapper"> <div class="range__slider__item"> <div class="range__slider__img"><img src="img/production-items-1.png"></div> <div class="range__slider__info mCustomScrollbar"> <div class="range__slider__info__title">Идейные соображения высшего порядка, а также укрепление </div> <p class="range__slider__info__description">Номенклатура конвейерных лент Nitta по-настоящему широкая</p></div> </div> </div> </div> <div class="range__read-more--link">Читать дальше</div> You need to add a class to range__slider__item - wrapper
And how to do that when we add a class to all the child blocks, the button is hidden? I added
if (curSlide > slides.length) { $('.range__read-more--link').hide(); } But, it disappears when you press a button, and I need, when the last child is shown, then we hide the button.
Question solved, forgot to add> = instead of>
children()not take what you need? - Regent