jquery滑块改变背景位置
我正在努力使用 jquery 滑块设置和更改背景图像位置。
我的滑块与以下代码配合得很好:
$(function() {
$( "#slider" ).slider({
value:5,
min: 0,
max: 10,
step: 1,
slide: function( event, ui ) {
$( "#amount" ).val( ui.value );
}
});
$( "#amount" ).val( $( "#slider" ).slider( "value" ) );
});
但是,我现在想要更改图像的背景位置。我添加了这段代码:
$(".beer_slider").css("background-position").val( $( "#slider" ).slider( "value" ) );
但是什么也没发生!
有人指出我应该包含以下变量:
var beer_slider = {
"0": "-200px",
"1": "-190px",
"2": "-180px",
"2": "-170px",
"3": "-160px",
"4": "-150px",
"5": "-140px",
"6": "-130px",
"7": "-120px",
"8": "-110x",
"9": "-100x",
"10": "-90x",
};
但我不知道如何调用它。
任何帮助表示赞赏
I'm struggling to set and change a background image position using jquery slider.
My slider's working pretty well with the following code:
$(function() {
$( "#slider" ).slider({
value:5,
min: 0,
max: 10,
step: 1,
slide: function( event, ui ) {
$( "#amount" ).val( ui.value );
}
});
$( "#amount" ).val( $( "#slider" ).slider( "value" ) );
});
However, I now want to change the background position of an image. I have added this code:
$(".beer_slider").css("background-position").val( $( "#slider" ).slider( "value" ) );
But nothing really happens!
Someone pointed out I should include the following variables:
var beer_slider = {
"0": "-200px",
"1": "-190px",
"2": "-180px",
"2": "-170px",
"3": "-160px",
"4": "-150px",
"5": "-140px",
"6": "-130px",
"7": "-120px",
"8": "-110x",
"9": "-100x",
"10": "-90x",
};
But I'm not sure how to call that.
Any help appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你能不做吗
?
Can you not do
?