переделал логику на tabs
This commit is contained in:
@@ -73,35 +73,26 @@ function checkPhone(input) {
|
||||
})
|
||||
}
|
||||
|
||||
inputTwo('.form-input__two', '.form-input-two__input')
|
||||
inputTabs('.form-input__tabs', '.form-input-tabs__button');
|
||||
|
||||
function inputTwo(main, inputTwo) {
|
||||
let buttons = document.querySelectorAll(main);
|
||||
function inputTabs(main, button) {
|
||||
let mains = document.querySelectorAll(main);
|
||||
|
||||
buttons.forEach(button => {
|
||||
let input = button.querySelector(inputTwo);
|
||||
|
||||
button.onclick = function () {
|
||||
input.checked = (input.checked == false) ? true : false;
|
||||
mains.forEach(main => {
|
||||
let buttons = main.querySelectorAll(button);
|
||||
|
||||
if (button.dataset.content) {
|
||||
let content = button.dataset.content,
|
||||
childrens = document.querySelector(`.${content}`).children;
|
||||
|
||||
Object.keys(childrens).forEach(blockId => {
|
||||
let block = childrens[blockId];
|
||||
buttons.forEach(button => {
|
||||
button.onclick = function () {
|
||||
main.querySelector('.active').classList.remove('active');
|
||||
|
||||
if (block.classList.contains('active')) {
|
||||
block.classList.remove('active');
|
||||
}else{
|
||||
block.classList.add('active');
|
||||
}
|
||||
})
|
||||
button.classList.add('active');
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
inputRadio('.form-input__radio', '.form-input-radio__item', '.form-input-radio__title', '.form-input-radio__input')
|
||||
|
||||
function inputRadio(main ,item, textClass, input) {
|
||||
|
||||
Reference in New Issue
Block a user