gpt4 book ai didi

jquery - 使用 jQuery 即时更新范围值

转载 作者:可可西里 更新时间:2023-11-01 13:10:14 25 4
gpt4 key购买 nike

我有一个范围,我想立即更新显示其数值的跨度。我的代码有效,但仅在您停止按住左键单击时才显示数值。

这是我所拥有的:

$("#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 .

最佳答案

您可以同时检查 inputchange实现这一目标的事件。

在这种情况下:

$("#length").on('input change', function(){
$("#password-length").html(this.value);
});

jsFiddle here

关于jquery - 使用 jQuery 即时更新范围值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24728703/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com