Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/415.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/2/jquery/71.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 jQuery UI-从范围滑块中选择一个类_Javascript_Jquery - Fatal编程技术网

Javascript jQuery UI-从范围滑块中选择一个类

Javascript jQuery UI-从范围滑块中选择一个类,javascript,jquery,Javascript,Jquery,我目前正在使用jqueryui,我试图获取最小和最大处理程序的left属性的值 为此,我将此javascript代码用于price_范围,在本例中,一切正常 function GetLeftValue(){ var element = document.getElementById('price_range'), left = element.getBoundingClientRect().left, windowWidth = window.innerWidth; va

我目前正在使用jqueryui,我试图获取最小和最大处理程序的left属性的值

为此,我将此javascript代码用于price_范围,在本例中,一切正常

function GetLeftValue(){
   var element = document.getElementById('price_range'),
   left = element.getBoundingClientRect().left,
   windowWidth = window.innerWidth;
   var num = (Number(((left / windowWidth) * 100).toFixed(1))+ "%");
   alert(num);
} 
但当我尝试将其用于具有以下类的两个处理程序时:

.ui-slider-handle .ui-corner-all .ui-state-default 
我无法使用带有getElementsByClassName的js函数联系到他们当然:

var element = document.getElementsByClassName('class')
我试了以前的每一门课

我还尝试了与我的函数相关的jQuery,我不确定它是否是选择元素的有效方法:

var element = document.$('#slider-range > span:nth-child(2)') /*minimum handler*/
最后,我认为不知何故,元素应该是一个id,这样它就可以正常工作,我尝试在前面的类中添加一个id:

$('.class').attr("id","myId");
这仍然未能实现我的期望


有人能帮我澄清一下这个情况吗?谢谢。

您想要这份工作吗

let minvalue = $(".ui-slider-handle:eq(0)").css("left");  
let maxvalue = $(".ui-slider-handle:eq(1)").css("left"); 

编辑:有一些输入错误。

是的,似乎它在做它的工作,我只需要将输出转换成我在函数中使用的百分比,但我仍然不明白为什么我的选择器不工作!