Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7658919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:15:52+00:00 2026-05-31T13:15:52+00:00

Im pretty new to HTML5/Javascript/CSS3 and im confused on exactly how to pass the

  • 0

Im pretty new to HTML5/Javascript/CSS3 and im confused on exactly how to pass the id of my event listener to the new function. I’m building a video player and this is the volume up and down part, and I would rather be able to use one function for both volume up and volume down using if statements, which would check the id.

Here is what im working with:

 volume_up = document.getElementById('volume_up'); //get the volume_up button
 volume_up.addEventListener('click', volumeUp, false); //call function "volumeUp" on click

Here is the “volumeUp” function:

function volumeUp(click_button){
alert(click_button.id); // i want to be able to get the id here
myMovie.volume = myMovie.volume - 0.1;
}

If i was able to get the ID, i could do vol up and vol down in this one function instead of 2 via if statements.

I have tried doing this:

   volume_up.addEventListener('click', volumeUp(volume_up), false);

and

    volume_up.addEventListener('click', volumeUp(volume_up.id), false);

with no luck. I have the volume up button linked up, and whenever i press it, the volume does change, and the alert does popup, but it says undefined.

Any help would be appreciated. Thanks 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:15:52+00:00Added an answer on May 31, 2026 at 1:15 pm

    In the event handler “this” is bound to the element that fired the event, so you can just use “this.id”.

    Check out this example: http://jsfiddle.net/vyGdJ/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am pretty new to JavaScript and jQuery and getting a little confused with
New to MVC, so hopefully this will be pretty simple. I have an HTML
I'm pretty new to the idea of recursion and this is actually my first
I'm pretty new to wordpress, html, css, and javascript and would love your help
I'm pretty new to wordpress, html, css, and javascript and would love your help
I know this sounds pretty trivial, but I'm new to jQuery... I use this
So I am pretty new to both Django and Javascript (I am using JQuery)
I just started learning javascript for 2 weeks so I'm pretty new to it.
I have just entered the world of jquery and am pretty new to javascript
I'm pretty new to javascript and jquery, and have run into a problem that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.