【发布时间】:2018-08-02 10:54:46
【问题描述】:
我对我的 jQuery UI 图像滑块有疑问。我喜欢添加两个以上的图像来改变,但我不知道怎么做。我应该更改什么以添加更多图像以使用滑块进行更改? 以及如何使图像居中,此时它向左浮动。 非常感谢!
$(function() {
$("#slider1").slider({
min: 0,
max: 2,
step: 1,
change: function(event, ui) {
if (ui.value == 1) {
$('#flask').attr('src', 'img/tweet1.png');
} else {
$('#flask').attr('src', 'img/tweet2.png');
};
}
});
});
#slider1 {
align-content: center;
margin-left: 15em;
margin-right: 15em;
margin-top: 5em;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<img src="img/tweet2.png" height="270" width="600" id="flask" />
<div id="slider1">
【问题讨论】:
-
您的代码 sn-p 不起作用
标签: javascript jquery html css jquery-ui