我有一个范围,我想立即更新显示其数值的跨度。我的代码有效,但仅在您停止按住左键单击时才显示数值。
这是我所拥有的:
$("#length").change(function(){ // when range is altered, execute function
len = $("#length").val(); // set variable "len" to the numeral value of range
$("#password-length").html(len); // set "len" (numeral value) to a span
});
Fiddle .
最佳答案
您可以同时检查 input
和 change
实现这一目标的事件。
在这种情况下:
$("#length").on('input change', function(){
$("#password-length").html(this.value);
});
关于jquery - 使用 jQuery 即时更新范围值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24728703/