demarches-normaliennes/app/javascript/new_design/support.js
2019-02-21 18:05:47 +01:00

18 lines
438 B
JavaScript

import { show, hide, delegate } from '@utils';
delegate('change', '#contact-form #type', event => {
const type = event.target.value;
const answer = document.querySelector(`[data-answer="${type}"]`);
const card = document.querySelector('.support.card');
for (let element of document.querySelectorAll('.card-content')) {
hide(element);
}
if (answer) {
show(card);
show(answer);
} else {
hide(card);
}
});