0
我想要一個類似於this之一的jQuery /任何滑塊,但功能稍多一些。以特定值顯示元素的滑塊
我將在我的HTML代碼中包含元素,圖像,文本和一些div,默認情況下應該隱藏這些元素,但是當滑塊達到特定值時,圖像/文本/任何內容應該連續顯示。
因此,在值爲0的情況下,例如,只顯示一個圖像,然後在值1時彈出另一個圖像,依此類推。
是否有任何預製的jQuery插件,或者我會怎麼做呢?
<!DOCTYPE html>
<html>
<head>
<title>jQuery Mobile Tutorial on Codeforest.net</title>
<link rel="stylesheet"
href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css">
<style>
#slider {
margin: 10px;
}
</style>
<script src="http://code.jquery.com/jquery-1.9.0.js"></script>
<script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>
<script>
var img1 = $('<img\>').attr('src', 'http://lorempixel.com/400/200/');
var img2 = $('<img\>').attr('src', 'http://lorempixel.com/300/200/');
var foto = $('#foto');
foto.html(img1);
$("#slider").slider({
slide: function(event, ui) {
if (ui.value > 50) {
$('#foto').html(img2);
} else {
$('#foto').html(img1);
}
}
});
</script>
</head>
<body>
<div id="slider"></div>
<div id="foto"></div>
</body>
</html>
我試圖用你的榜樣(請參閱我的MWE),但我沒有按」什麼都不顯示。我做錯了什麼? – cherrun
確保您將其包裝在document.ready函數中 或將其加載到頁面的底部。 – Dieterg