Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 拖动时更改滑块_Javascript_Jquery_Html_Range - Fatal编程技术网

Javascript 拖动时更改滑块

Javascript 拖动时更改滑块,javascript,jquery,html,range,Javascript,Jquery,Html,Range,我有一个Javascript滑条,它使用一个数组作为选项。但是,它不会随着拖动而更改 var img=document.getElementById('img'); 变量img_数组=['http://www.w3schools.com/images/w3logotest2.png', 'http://www.w3schools.com/html/img_html5_html5.gif']; 功能设置映像(obj){ var值=目标值; img.src=img_数组[值]; } 移动var i

我有一个Javascript滑条,它使用一个数组作为选项。但是,它不会随着拖动而更改

var img=document.getElementById('img');
变量img_数组=['http://www.w3schools.com/images/w3logotest2.png', 'http://www.w3schools.com/html/img_html5_html5.gif'];
功能设置映像(obj){
var值=目标值;
img.src=img_数组[值];
}

移动
var img=document.getElementById('img')在函数内部

var img_数组=[]http://www.w3schools.com/images/w3logotest2.png', 'http://www.w3schools.com/html/img_html5_html5.gif'];
功能设置映像(obj)
{
var img=document.getElementById('img');
var值=目标值;
img.src=img_数组[值];
}

使用oninput而不是onchange

()

var img=document.getElementById('img');
变量img_数组=['http://www.w3schools.com/images/w3logotest2.png', 'http://www.w3schools.com/html/img_html5_html5.gif'];
功能设置映像(obj){
var值=目标值;
img.src=img_数组[值];
}


没有问题,为我工作->没有,我想在与滚动条交互时更改图像。目前,你必须在图像更改之前放手。更改事件仅在交互结束时触发,因此你需要使用它有效的东西,谢谢!