$('input').on('focus blur', function(e) {
$(this).toggleClass('active', e.type === 'focus');
});
const onFocus = e => e.target.classList.toggle('active', e.type === 'focus');
document.querySelectorAll('input').forEach(n => {
n.addEventListener('focus', onFocus);
n.addEventListener('blur', onFocus);
});