How do I detect if a HTMLElement range slider has been changed?

0 favourites
  • 1 posts
From the Asset Store
Simplistic hyper-casual game with nature elements. Tap to switch between the 4 elements and reach a better score.
  • I have a HTMLElement with lots of things going on inside it. One of those things is a range slider with an id of 'slider-1'.

    I want to change a value (some variable) in the event sheet when this slider has been changed. I can see there is a htmlElement onClicked event for buttons which works great, but I can't find anything for a slider.

    How would I do this?

    I tried the following javascript snippet. It does nothing but I have a feeling I might be on the right track ...

    var slider = document.getElementById("slider-1");
    var textElement = document.getElementById("val-1");//a text element to display the current value
    
    slider.addEventListener("input", function() {
     
    	var sliderValue = this.value;
     textElement.textContent = sliderValue;
     
    });
    

    Thanks

    Tagged:

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)