So basically the idea is to start a presentation of different fonts/typography with simple options the first one being the possibility to change the size of each font. So I tried a very non-economical logic by changing the querySelector with a class but it seems to only take the first input range slider that changes the whole body. My question is how can I make multiple input range sliders that can change specific things (here the example is size but later on I would like to add spacing, line height & width per font). So I don't know how to get around this and apply one input slider to a certain class?
document.querySelector('input').addEventListener('input', e => document.querySelector('.font_1').style.fontSize = e
.target.value + 'em');
document.querySelector('input').addEventListener('input', e => document.querySelector('.font_2').style.fontSize = e
.target.value + 'em');
document.querySelector('input').addEventListener('input', e => document.querySelector('.font_3').style.fontSize = e
.target.value + 'em');
document.querySelector('input').addEventListener('input', e => document.querySelector('.font_4').style.fontSize = e
.target.value + 'em');
document.querySelector('input').addEventListener('input', e => document.querySelector('.font_5').style.fontSize = e
.target.value + 'em');
document.querySelector('input').addEventListener('input', e => document.querySelector('.font_6').style.fontSize = e
.target.value + 'em');
body {
margin: 0;
padding: 0;
box-sizing: border-box;
height: 100vh;
width: 100vw;
overflow: hidden;
}
<div class="container">
<header>
<label>Change font-size</label>
<input type="range" value="1.2" min="1.2" max="2.6" step=".0002" id="slider" />
<p class="font_1">Some text that should dynamically change size.</p>
<label>Change font-size</label>
<input type="range" value="1.2" min="1.2" max="2.6" step=".0002" id="slider" />
<p class="font_2">Some text that should dynamically change size.</p>
<label>Change font-size</label>
<input type="range" value="1.2" min="1.2" max="2.6" step=".0002" id="slider" />
<p class="font_3">Some text that should dynamically change size.</p>
<label>Change font-size</label>
<input type="range" value="1.2" min="1.2" max="2.6" step=".0002" id="slider" />
<p class="font_4">Some text that should dynamically change size.</p>
<label>Change font-size</label>
<input type="range" value="1.2" min="1.2" max="2.6" step=".0002" id="slider" />
<p class="font_5">Some text that should dynamically change size.</p>
</header>
</div>