demarches-normaliennes/app/javascript/new_design/support.js

19 lines
438 B
JavaScript
Raw Normal View History

2019-02-21 17:50:18 +01:00
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);
}
});