有没有办法在 onchange
事件中的输入更改之前提取输入标记的值?或者在“更改”之前是否触发了事件?
特别是我需要它的类型范围。
这个问题增加了之前提出的类似问题,因为我也 询问在更改之前是否没有办法“捕获”该值 在许多其他编程语言中。
<form >
<input type="range" value="0" id="indentA" name="indentA" min="-20" max="20" onchange="alert('trying to output original value here... \ncurrent value is: '+this.value);" >
</form>
最佳答案
这是您要找的人吗? 当 slider 更改时,我正在捕获旧值。 请看下面的代码片段。
Code Snippet
var previos_value=0;
function getValue(value){
alert('current value is: '+value);
alert('Previous value is: '+previos_value);
previos_value=value;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script>
<form >
<input type="range" value="0" id="indentA" name="indentA" min="-20" max="20" onchange="getValue(this.value)" >
</form>
关于javascript - onchanged 事件,在更改之前获取值?在 html 输入标签中(类型=范围),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31344723/