How to update html5 range on change of a text input?

前端 未结 6 1481
忘掉有多难
忘掉有多难 2021-02-07 13:59

I have a html5 range input and a text box input. When the range changes, the text box will get updated. But what should I do so that when I put a number in the text box, the ran

6条回答
  •  难免孤独
    2021-02-07 14:46

    This fiddle works:

    var slider = document.getElementById('slider');
    $('#box').change(function(){
        slider.value=parseInt(this.value);
    });
    

    (So that's your current code, actually. Did you import the jQuery library?)
    Keep in mind that you've set the slider's range to 200. Try some values between 0 and 200.

提交回复
热议问题