CSS
3
Вклад в тег
<form action="#" class="quiz__form_tourists">
<button class="quiz__tourists-btn">
Добавить ребёнка
</button>
<div class="years-old__inputs"></div>
</form>
<div class="quiz__block_years-old-wrap">
<div class="years-old__title">
Выберите возраст ребёнка
</div>
<div class="quiz__block_years-old">
<button class="years-old__item years-old-1 box-shadow-hover">
больше 2 лет
</button>
</div>
</div>
let formTourists = document.querySelector('.quiz__form_tourists');
let btnTourists = document.querySelector('.quiz__tourists-btn');
let yearsOldBlock = document.querySelector('.quiz__block_years-old-wrap');
btnTourists.addEventListener('click', function(e) {
e.preventDefault();
formTourists.style.display = 'none';
yearsOldBlock.style.display = 'block';
});
let yearsOld1 = document.querySelector('.years-old-1');
yearsOld1.addEventListener('click', function(e) {
e.preventDefault();
formTourists.style.display = 'block';
yearsOldBlock.style.display = 'none';
let yearsInputs = document.querySelector('.years-old__inputs');
let str = '<div class="years-input-wrap"><button class="years-input-remove">х</button><input type="text" class="years-input" placeholder="ребёнок до 2-х лет"></div>';
yearsInputs.innerHTML += str;
let inputRemove = document.querySelectorAll('.years-input-remove');
for(let i = 0; i < inputRemove.length; i++){
inputRemove[i].addEventListener('click', function(e) {
e.preventDefault();
e.currentTarget.parentNode.remove();
});
}
});
<p> Автор поста: <?php the_author_meta('display_name',$user_id); ?></p>