Trying to get the volume slider to work

What’s missing, and needed here is the javascript for the volume slider.

I’m not sure how that would be written.


<audio controls class="player">
  <source src="" type="audio/mpeg">

<button class="style" onclick="document.querySelector('.player').play()">Play</button>
<button class="style" onclick="document.querySelector('.player').pause()">Pause</button>

<div class="volbox">
  <input class="volume" type="range" min="0" max="100" step="0.1">

I’m seeing that there are numerous ways this code could be written.

And range is used for the slider.

You already have play/pause controls by adding “controls” in your audio tag. Why use buttons as well?

Because I’m going to remove the controls from it. And so, I thought to do that, I would want to add in a volume slider as a way to control the volume.

To set that part up, javascript would be needed.

<audio class="player">


It would help if you got your code right before posting then, save wasting people’s time reviewing something you intend to change.

I’m not wasting people’s time, I’m trying to figure out how to get the volume slider to work.

That’s what my question was.

I should have have made it more clear, I’m sorry.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.