Volume slider missing on Handel?

I'm having an issue with my volume slider in jQuery - the handle is not showing up despite it working.

Any suggestions on how to make the handle visible?

The jQuery I have imported:

<script src="jquery-3.4.1.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js"></script>

Below is the JavaScript code to manage volume changes, along with its HTML and CSS.

$("#volume").slider({
  min: 0,
  max: 100,
  value: 0,
range: "min",
  slide: function(event, ui) {
    setVolume(ui.value / 100);
  }
});

function setVolume(myVolume) {
    if (audioElement != undefined) {
      audioElement.volume = myVolume;
    }
}
.audioUtilitiesDiv {
  width: 20%;
  display: inline-block;
  background-color: lightblue;
}

#player {
width: 350px;
height: 50px;
position: relative;
margin: 0 auto;
top: 80px;

i {
position: absolute;
margin-top: -6px;
color: #666;
}

i.fa-volume-down {
margin-left: -8px;
}

i.fa-volume-up {
margin-right: -8px;
right: 0;
}
}

#volume {
position: absolute;
left: 24px;
margin: 0 auto;
height: 5px;
width: 300px;
background: #555;
border-radius: 15px;

.ui-slider-range-min {
height: 5px;
width: 300px;
position: absolute;
background: green;
border: none;
border-radius: 10px;
  outline: none;
}

.ui-slider-handle {
width: 20px;
  height: 20px;
border-radius: 20px;
  background: #FFF;
  position: absolute;
  margin-left: -8px;
  margin-top: -8px;
  cursor: pointer;
  outline: none;
}
}
    <div class="audioUtilitiesDiv">
      <div id="player">
        <i class="fa fa-volume-down"></i>
        <div id="volume"></div>
        <i class="fa fa-volume-up"></i>
      </div>
    </div>

If anyone could provide assistance on this matter, please feel free to reach out. Thank you in advance!

Answer №1

For Slider to function correctly, it is essential to include the necessary jQuery, jQuery UI, and CSS libraries. Additionally, I have identified a few syntax errors in the CSS code that need to be addressed. Take note of the following suggestions.

$(function() {
  var audioElement = $("<audio>");

  function setVolume(myVolume) {
    if (audioElement != undefined) {
      audioElement.volume = myVolume;
    }
  }

  $("#volume").slider({
    min: 0,
    max: 1,
    value: 0,
    step: 0.1,
    range: "min",
    slide: function(event, ui) {
      setVolume(ui.value);
    }
  });
});
.audioUtilitiesDiv {
  display: inline-block;
  background-color: lightblue;
}

#player {
  width: 350px;
  height: 50px;
  position: relative;
  margin: 0 auto;
  top: 80px;
}

i {
  position: absolute;
  margin-top: -6px;
  color: #666;
}

i.fa-volume-down {
  margin-left: -8px;
}

i.fa-volume-up {
  margin-right: -8px;
  right: 0;
}

#volume {
  position: absolute;
  left: 24px;
  margin: 0 auto;
  height: 5px;
  width: 300px;
  background: #555;
  border-radius: 15px;
}

.ui-slider-range-min {
  height: 5px;
  width: 300px;
  position: absolute;
  background: green;
  border: none;
  border-radius: 10px;
  outline: none;
}

.ui-slider-handle {
  width: 20px;
  height: 20px;
  border-radius: 20px;
  background: #FFF;
  position: absolute;
  margin-left: -8px;
  margin-top: -8px;
  cursor: pointer;
  outline: none;
}
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<div class="audioUtilitiesDiv">
  <div id="player">
    <i class="fa fa-volume-down"></i>
    <div id="volume"></div>
    <i class="fa fa-volume-up"></i>
  </div>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Ways to transform a 4-column CSS table into a 2-column layout for mobile and tablet viewing

For my latest project, I am faced with the challenge of creating a responsive table that transforms from 5 columns to 2 columns on smaller screens. While using complex jQuery is an option, I prefer a more semantic approach. Additionally, I need to incorpor ...

What is the best way to implement JQuery in order to trigger an event in a text box whenever the user hits the "enter

Also, refrain from submitting the form if the user hits enter in THAT PARTICULAR input field. ...

Ways to include margin right for a table

Here is the HTML code I am working with: <table width="100%;> <tr><hr style="width:100%;"></hr></tr> <tr> <span style="float:left">abc</span> <span class="noindex" ...

Guide to vertically centering Font Awesome icons inside a circular div

Is there a way to perfectly center align font awesome icons vertically? I have tried using the line-height property when text is present, and even setting the line-height equal to the height of the div. Attempts with display:inline-block and vertical-alig ...

"Exploring the usage of URL parameters within the jQuery .ajax() function

I came across an example on the web that explains how communication works between Jquery, Json, and PHP. It provides a clear explanation of options like .$ajax() or $.post(). One thing that stood out to me was the parameter URL used in all cases: url:&ap ...

I found myself pondering the method to achieve the slightly blue tinted box that sits behind the image

Can you assist me in achieving this specific look? I have my MUI app bar and home page set up, but I'm unsure how to create the blue-ish box behind the image. Should I place the container within my app bar or integrate it into my homepage file? Additi ...

Can pagination numbers in Jquery DataTable be configured based on the total records returned by the server and the number of records chosen by the user?

I am currently diving into the world of DataTable.js, a jQuery plugin, and working hard to articulate my questions effectively. For my specific needs, I need to retrieve only 10 records initially whenever an AJAX request is made, even if there are 100 rec ...

Having difficulty adjusting the width of a jQuery multi-select dropdown menu

Utilizing a jquery multi select for a dropdown to enable users to select multiple items at once. Html Code: <div class="jobdiv"> <img src="~/Images/traj.png" width="22" height="24" /> @Html.DropDownListFor(model => Model.TrajName, ...

CSS changes on child elements cause conflicts with parent hover effects

I've come across the following html code : .logo { display: inline-block; width: 30px; position: absolute; top: 50%; opacity: 0; transition: 0.6s; } .container:hover .logo { opacity: 1; transition: 0.6s; } .container:hover .pictur ...

Show the components only if the final digit in their identification number is less than i

I have several span elements with IDs like "tag1", "tag2", etc. I want to display only the spans whose ID ends with a number less than 19. These elements are part of a class called "notVis", which is hidden by default using $(".notVis").hide(); when the ...

bootstrap 4 - logo in navbar brand stays the same even when scrolling

I integrated Bootstrap 4 and successfully created a navbar. However, I am encountering a conflict when trying to change the navbar logo upon scrolling down. Despite my efforts, it is not functioning as expected. Does anyone know how to resolve this issue? ...

Hide the cursor when the text box is in focus

Is there a way to remove the cursor from a textbox when it is clicked on? I want the cursor to disappear after clicking on the textbox. jQuery(document).ready(function($) { $(function(){ $('#edit-field-date-value-value-datepicker-popup-0&ap ...

How can I use the jQuery library along with the Ajax method to search for listings on CraigsList?

Earlier, I attempted to query craigslist for a page but was unsuccessful in doing so. My goal is to retrieve the page from: through an ajax call, parse the html, and work with the results. For this question, my focus is solely on successfully querying an ...

Obtain Jsonp Callback and data from a WCF Service

Thank you for all your amazing assistance thus far! I have been making great strides with my project. However, I've hit another roadblock that I can't seem to overcome. The function in my service Interface appears as follows: <OperationC ...

Retrieve the chosen item from the autocomplete feature

Unfortunately, I have encountered an issue with this solution as I was unable to get it to work correctly in my code. The objective is to retrieve the selected item and then call another function to utilize it. The script is as follows: <script type=" ...

Preventing Javascript Pop Up from automatically jumping to the top of the page

Upon clicking a button (refer to image below and take note of the scroll bar position), a div pop up is triggered through Javascript. View image: https://docs.google.com/file/d/0B1O3Ee_1Z5cRTko0anExazBBQkU/preview However, when the button is clicked, the ...

How to update the border color of focused elements in ExtJS?

In my ExtJS application running on ExtJS 6 with the default Theme-Triton, I am looking to customize the focus border color. Is there a solution to modify the CSS property that will globally change the focus border color from blue to red, for instance? ...

Failure to trigger AJAX error function when database match is not located

UPDATED: Having some issues with my code entry box when a match is not found in the database. Below are the results for both a good and bad match. Check out my code snippet: function checkDiscountCode() { var discount; if ($('#dbReturnString') ...

Creating dynamic HTML elements for each section using JavaScript

Is there a way to dynamically add a task (input + label) for each specific section/div when entering the name and pressing the "Add" button? I attempted to create an event for each button to add a task for the corresponding div of that particular section, ...

Creating Dynamic HTML Links with C# Programming

In the web application I am working on, there is a menu that looks like this: <div> <ul> <li><a href="http://localhost:52451/Voronezh/Settings.aspx">Settings</a</li> <li><a href="http://localhost:52451/L ...