Раскрывашка стандартной кнопкой на про тарифе
- Создаёте кнопку со значением "javascript:void(0)" вместо ссылки (без кавычек)
- Снизу от кнопки делаете любой блок, который должен открываться
- Между этими блоками добавляете код
В самый низ страницы добавляете код
<script>
Array.from(document.querySelectorAll('.exp')).map((exp) => {
var expandbtn = exp.parentElement.parentElement.parentElement.previousSibling;
expandbtn.classList.add('expandbtn')
var expandedcontent = expandbtn.nextSibling.nextSibling;
expandedcontent.classList.add('not-expanded')
var expanded = false;
expandbtn.onclick = function () {
if (expanded === false) {expandedcontent.classList.remove('not-expanded')
expanded = true}
else {expandedcontent.classList.add('not-expanded')
expanded = false}
}
});
</script>
<style>
.not-expanded {
height: 0px;
padding: 0px;
opacity: 0;
transform: translate(0px, -30px);
transition: all 0.2s linear;
}
.block-item {
transition: all 0.2s linear;
}
.expandbtn {
position: relative;
}
.expandbtn::after {
position: absolute;
content: "Подробнее";
right: 10px;
bottom: -5px;
font-size: 14px;
color: #eee;
background: tomato;
border-radius: 6px;
padding: 3px 7px;
}
Готово! Теперь у вас открывается скрытый блок по нажатию кнопки!