[英]Access to a value within the span tag
I'm trying to modify this range slider . 我正在尝试修改此范围滑块 。 Since I have to incorporate this slider in another file I need to understand how it works.
由于我必须将此滑块合并到另一个文件中,因此我需要了解它的工作原理。 In particular I would like to know where the code returns the selected year.
我特别想知道代码在哪里返回所选年份。
I tried adding these prints but it doesn't print the correct year. 我尝试添加这些打印件,但是无法打印正确的年份。
var rangeSlider = function() {
var slider = $('.range-slider');
var range = $('.range-slider__range');
var value = $('.range-slider__value');
// added print
console.log(value);
slider.each(function() {
value.each(function() {
var value = $(this).prev().attr('value');
$(this).html(value);
// added print
console.log(value);
console.log(value.innerHMTL);
console.log(value.innerText);
});
range.on('input', function() {
$(this).next(value).html(this.value);
});
});
};
rangeSlider();
Looking on Chrome, I see that the value being edited is in span
. 在Chrome上查看,我看到正在编辑的值在
span
。 I can't access to that value.
我无法获得该价值。 How can I do that?
我怎样才能做到这一点?
Thanks 谢谢
The content of an element can be accessed using text()
method. 可以使用
text()
方法访问元素的内容。 For example: 例如:
$('#your_element').text();
您可以尝试命名每个输入(例如,添加id="Slider_1"
),然后使用JQUERY检索或设置值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.