Javascript 未捕获引用错误:bind()上赋值的左侧无效
我正在尝试将侦听器连接到视频以更新某些自定义控件上的输入范围,并收到一个错误,显示为Javascript 未捕获引用错误:bind()上赋值的左侧无效,javascript,jquery,Javascript,Jquery,我正在尝试将侦听器连接到视频以更新某些自定义控件上的输入范围,并收到一个错误,显示为uncaughtreferenceerror:assignment中的左侧无效 $(document).on('click', '.play-pause', function() { const video = $(this).closest('.video-container').children('video').get(0); if (video.paused == true) {
uncaughtreferenceerror:assignment中的左侧无效
$(document).on('click', '.play-pause', function() {
const video = $(this).closest('.video-container').children('video').get(0);
if (video.paused == true) {
video.play();
$(this).closest('.video-container').children('video').bind('timeupdate', function() {
let value = (100 / video.duration) * video.currentTime;
$(this).closest('.video-container').find('.seek-bar').val() = value;
})
$(this).children('svg').remove();
$(this).html(
`<i class="fas fa-pause fa-fw"></i>`
);
} else {
video.pause();
$(this).children('svg').remove();
$(this).html(
`<i class="fas fa-play fa-fw"></i>`
);
}
});
$(文档)。在('单击','播放暂停',函数()上){
const video=$(this).closest('.video container').children('video').get(0);
如果(video.paused==true){
video.play();
$(this).closest('.video container')。children('video')。bind('timeupdate',function()){
let值=(100/video.duration)*video.currentTime;
$(this).closest('.video container').find('.seek bar').val()=值;
})
$(this.children('svg').remove();
$(this.html)(
``
);
}否则{
video.pause();
$(this.children('svg').remove();
$(this.html)(
``
);
}
});
这不是在jQuery中为元素设置值的方式:
$(this).closest('.video-container').find('.seek-bar').val() = value;
:
如错误所述,不能将函数调用用作变量赋值的目标。将值分配给变量,而不是函数。如果要使用赋值运算符分配值,则需要使用纯js
$(this).closest('.video-container').find('.seek-bar')[0].value = value;
您只能将值分配给变量或属性,因为您试图将值分配给函数的输出val()=value
$(this).closest('.video-container').find('.seek-bar')[0].value = value;