Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/21.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 - Fatal编程技术网

Javascript 动态更改输入值

Javascript 动态更改输入值,javascript,jquery,html,Javascript,Jquery,Html,我使用这个函数用javascript更改范围输入值 changeMenuValue : function(element, newValue){ document.getElementById(menuElements[element].id).value = newValue; }, 该函数适用于文本输入字段,但不会更改输入范围 这里有一个例子 app.changeMenuValue(rangeElementId, 17); console.log(rangeElement.valu

我使用这个函数用javascript更改范围输入值

changeMenuValue : function(element, newValue){
    document.getElementById(menuElements[element].id).value = newValue;
},
该函数适用于文本输入字段,但不会更改输入范围 这里有一个例子

app.changeMenuValue(rangeElementId, 17);
console.log(rangeElement.value);
此代码记录元素的初始值,但仍然不是新值17

我还尝试了jQuery方法

$("#rangeElementId").val(somevalue);
$("#rangeElementId").attr('value', '1');

代码app.changeMenuValuerangeElementId,17将id和值传递给函数,但函数changeMenuValue:functionelement,newValue需要元素和值。

对我有效,元素是否已禁用?问题出在其他地方,因为$rangeElementId.valsomevalue;实际上,虽然它调用参数'element',但它被用作索引:menuElements[element]yes。我刚才说的是函数的签名和传递的参数。很抱歉,这是我的对象,但它实际上是元素ID,它最终是相同的东西。范围的最小值和最大值是什么?哎哟。对不起,用户3439376,你说得对。这就是我在心烦意乱时发布的内容。