gpt4 book ai didi

javascript - jQuery e.clientX 返回未定义

转载 作者:行者123 更新时间:2023-11-29 15:23:18 30 4
gpt4 key购买 nike

我在使用 jQuery 访问事件的事件坐标时遇到问题。我的代码如下。每当我更改音量 slider 时,它都会返回 undefined 而不是光标位置。

 $(document).ready(function(){
// for new browsers
$("input#volume").bind('input', function(e){
if (is_playing()) {
now_playing.volume = parseFloat((this.value/100));
// set the tooltp for the current volume
var vol_tooltip = Math.floor((this.value/100)*100);
// $(".seek_timer").remove();
console.log(e.clientX);
// $(".slider-wrap").append("<span class='seek_timer'>"+vol_tooltip+"</span>");
// $(".seek_timer").css("left",e.clientX-15+"px");
}
});
});

为什么 e.clientX 未定义?

最佳答案

您正在绑定(bind)到 input 事件,该事件不包含坐标 - 坐标仅出现在使用 MouseEvent interface 的事件中,例如 clickmousedownmouseup 事件。如果您希望能够通过 clientXclientY 属性。

关于javascript - jQuery e.clientX 返回未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41554549/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com