从jquery滑块获取值 [英] getting the value from a jquery slider

查看:53
本文介绍了从jquery滑块获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此滑块..我想用它来更改..的边距,但是我的问题是要从中获取价值.即使我试图通过这样的警报来显示值:

I'm working on this slider.. that I want to use to change the margin of a ..but my problem is getting the value out of it. even if I trie to show the value with an alert like this:

window.alert($( "#slider" ).val()); 

什么都没有出现.有人知道我做错了什么吗?

nothing shows up. Anyone an idea to what i;m doing wrong??

谢谢!!!

<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link href="./demo_files/jquery-ui.css" rel="stylesheet" type="text/css">
<link href="./styles.css" rel="stylesheet" type="text/css">
<script src="./demo_files/jquery.min.js"></script>
<script src="./demo_files/jquery-ui.min.js"></script>
<style>     
    #demo-frame > div.demo { padding: 10px !important; };
</style>


<script>
    function displayVals() {

        $( "#slider" ).slider();

        var step = $( "#slider" ).slider( "option", "step" );

        $( "#slider" ).slider( "option", "step", 20 );  


        var singleValues = $("#slider").val();  
        $("p").html("<b>Single:</b> " + singleValues); 

        $("#slider").change(displayVals);                       
};

</script>
</head>

<div class="demo">

<div id="slider"></div>

</div><!-- End demo -->

<p></p>

<script> displayVals();</script>
</body></html>

推荐答案

您需要:

var singleValues = $('#slider').slider('value');

(或'values',如果它是多手柄或范围滑块)

(or 'values' if it's a multi-handled or range slider)

http://jqueryui.com/demos/slider/#method-value

这篇关于从jquery滑块获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆