我正在使用这个滑块..我想用它来改变一个边距..但我的问题是从中获取价值。即使我试图通过这样的提醒显示价值:
window.alert($( "#slider" ).val());
什么都没有显示出来。任何人都知道我做错了什么?
THANX !!!
<!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>
答案 0 :(得分:1)
你需要:
var singleValues = $('#slider').slider('value');
(或'values'
如果它是多处理或范围滑块)