我使用的這個jQuery UI滑塊從http://jqueryui.com/slider/#steps 這是一個簡單的滑塊,具有3個步驟(1,2和3)和一個顯示圖片的div元素(「id_1」)。所以我現在真正想要的是圖片的變化取決於滑塊的位置。所以在位置「1」時,它顯示一張圖片,並且只要我將滑塊移動到位置2或3,該圖片就會改變。我該怎麼做?jQuery UI:當滑塊位置發生變化時的動作
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Slider - Snap to increments</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function() {
$("#slider").slider({
value: 100,
min: 1,
max: 3,
step: 1,
slide: function (event, ui) {
$("#amount").val("$" + ui.value);
}
});
$("#amount").val("$" + $("#slider").slider("value"));
});
</script>
</head>
<body>
<p>
<label for="amount">Donation amount ($50 increments):</label>
<input type="text" id="amount" style="border: 0; color: #f6931f; font-weight: bold;" />
</p>
<div id="slider"></div>
<div id="id_1" class="class_1"></div>
</body>
</html>
在此先感謝!
謝謝! ui.value的東西正是我所需要的。完美的作品! – Oinobareion 2013-04-04 12:29:48