Prevent mousedown event on input range html element and still let user drag slider

后端 未结 5 1457
情书的邮戳
情书的邮戳 2021-02-20 02:15

So is there a way to disable mousedown and / or click event on input range element but at the same time let user drag slider around and still fire on change event?

Disabl

5条回答
  •  没有蜡笔的小新
    2021-02-20 03:00

    Why not use "mouseup" instead of "click"?

    $("#slider").on('mousedown', function(event) {
        //event.preventDefault();
        /* Act on the event */
        console.log("mousedown", this.value);
    });
     $("#slider").on('mouseup', function(event) {
        //event.preventDefault();
        /* Act on the event */
        console.log("mouseup", this.value);
    });
    

    Is this what you are trying to accomplish? Experiment with the fiddle if you'd like. :-)

提交回复
热议问题