var input_fontweight = document.querySelector('[name=fontweight]'); console.log(input_fontweight); var h2 = document.querySelector('h2'); input_fontweight.addEventListener('input', function(e){ console.log(e.target.value); h2.style.fontWeight = e.target.value; });