How to retrieve the clientX value of a mousemove event on an HTML progress element using

Help needed in implementing a fully functional video progress bar.

Here is the code snippet:

html

<video class="video" width="612" height="350" preload="none" controls controlsList="nodownload" oncontextmenu="return false;">
    <source src="video.php?id=1" type="video/mp4">
</video>

<div class="controls">
    <button>play</button>
    <button>pause</button>
    <button>fullscreen</button>
    <button>widescreen</button> 
    <progress class="pbar" value="0" min="0" max="100"></progress>
</div>

js

let video = document.querySelector('.video');
let progressBar = document.querySelector('.pbar');

video.addEventListener('timeupdate', ()=>
{
    var percentage = Math.floor((100 / video.duration)*video.currentTime);
    progressBar.value = percentage;
    progressBar.innerHTML = percentage + "% played";
}
);


progressBar.addEventListener('mousemove', ()=>
{
    console.log(progressBar.clientX);
}
);

To clarify, I am trying to retrieve clientX or clientY values from the progress tag when using mousemove event. Any assistance would be appreciated. Thank you.

Answer №1

According to the explanations in the mousemove documentation, it is the event object passed to the callback function that contains the X and Y values, not the element itself. Here's an example to guide you:

progressBar.addEventListener('mousemove', e => {
    console.log(e.clientX, e.clientY);
});

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

Creating Overlapping Sections Using Bulma CSS

I'm currently diving into the world of Bulma and aiming to create a simple page layout with the following structure: <header> <hero> <section> <footer> However, I'm encountering an issue where these elements are overlapp ...

Launching a CSS modal window using C# backend code

Here is my HTML code snippet: <a id="PopUp" runat="server" href="#openModal">Open me</a> // This code opens a pop-up window using HTML <div id="openModal" runat="server" class="modalDialog"> <div> <a href="#close" t ...

Text located in the bottom right corner of the window with the use of JavaScript

Is there a way to replace text at the bottom right of the window, as opposed to the page, so that it remains fixed in the corner of the window? I'm looking to create a "share" link that is always visible. ...

Encountering a 404 error while trying to use the autolinker

I have been struggling with this issue for the past day and can't seem to solve it on my own. Essentially, I am attempting to use Autolinker.js to automatically convert URLs into clickable hyperlinks in my chat application. However, every time I try ...

Unable to extract attributes from a different model within Sails.js

I'm working on populating a customer model with attributes from the address.js model. However, when trying to post JSON using Postman, I keep getting a 500 Validation Error and struggling to pinpoint the cause of the issue. Any assistance would be gre ...

Node and Express API may continue to serve a cached response until a new one is requested

I am facing an issue with my Express API where the response from article requests is being cached and returning the previous article instead of the current one. My API connects to a database storing press articles, and this problem occurs when requesting a ...

Using XPath in Selenium to locate elements that are siblings and have multiple children

I hope I have presented my problem/question clearly. Below is the HTML code I am working with: <div class="class-div"> <label class="class-label"> <span class="class-span">AAAA</span> </label> <div class="class-div-a"&g ...

Incorporated React component from Rails-assets.org into a Rails application

I have been trying to incorporate a react component from rails-assets.org into my Rails application. Currently, I am using the react-rails gem to write react view in my application. Now, I want to use other react components such as react-router, react-sel ...

Scrolling vertically on android using Phonegap

Currently, I am working with a dynamic list on PhoneGap. Is there a way to implement a vertical scroller for a basic ul and li list? I attempted applying overflow:auto to the div, but even though the scroller is visible, it does not work as expected. I p ...

Chrome's Notification API requires some additional information

I've been experimenting with the code from this demo link: https://davidwalsh.name/demo/notifications-api.php The demo mentioned above functions perfectly on Chrome, Firefox, and Edge browsers. I utilized the demo to create an .aspx page by simply ...

What is the best way to store user data from an Angular App into the Firebase Realtime database?

As I delve into the world of Angular by following a tutorial, I find myself struggling with saving users to the Firebase database. Despite successfully logging in, the database remains empty. import { Injectable } from '@angular/core&apo ...

Css technique for changing color on mouse hover

I currently have a social media bar on my website with icons for Facebook, Twitter, Google+, and RSS. Here is how it looks: When I hover over the icons, I want the circle around the image to change color to blue. However, every attempt I've made end ...

Creating a Bootstrap 4.1 dropdown submenu on hover: A step-by-step guide

Currently, I am developing a website and I am looking to implement a dropdown submenu on hover using Bootstrap 4.1. Here is the HTML code snippet I have utilized to create the hover dropdown menu: <div class="navbar-collapse text-center" id="navbarRes ...

Experiencing a problem with loading scenes on a splash screen using WebGL and three.js

As a newcomer to SOF, I apologize for not being familiar with local customs. // Hello all! I am attempting to develop a 3D model with a splash screen and first-person movement using three.js and its examples. // Here is the source: // The issue at hand ...

Is it possible to achieve the full image when utilizing double buffering for drawing on canvas?

I have a code where I am using two canvas elements to draw an image in order to prevent flickering. However, I am facing an issue where I cannot get the full image to display when using this method. When I use just one canvas, the image displays fine. It ...

Using Vue.js with Vue Router to handle login functionality and automatically refreshing data

I am currently working on a Vue.js application and have successfully implemented authentication functionality, including checking if the user is logged in. After logging in, I want to fetch some data and store it in localStorage. However, I have encounter ...

"Enhancing User Experience with jQuery: Implementing a Smooth Scroll Feature with Current

I could really use some guidance on this issue that's been causing me trouble. Take a look at this fiddle for reference: http://jsfiddle.net/NtUpw/ Currently, the code is functioning as expected. However, I'm facing an issue where when the curre ...

I'm looking to utilize the Blueimp File Uploader to upload just one file

I'm trying to upload only one file using Blueimp File Upload. However, whenever I select a second file after uploading the first one, the new file gets appended below the old one instead of replacing it. How can I modify the code to replace the existi ...

Issue: Upon attempting to connect to a vsftpd server deployed on AWS using the npm module ssh2-sftp-client, all designated authentication methods have failed

Code snippet for connecting to the vsftpd server sftp.connect({ host: "3.6.75.65" port: "22" username: "ashish-ftp" password: "*******" }) .then(() => { console.log("result") }) .catch((err)=>{ ...

Make the background disappear when the text field is left empty and the cursor is not present (onUnfocus)

When the text field is empty and there is no cursor in the text field, I want it to be transparent and for the spell checker not working. The result should be displayed a little to the left inside a <div>. Should this be done using CSS, JavaScript, ...