多个 jquery 滑块不采用样式
我有一个多个 jQuery 滑块并为其编写自定义样式,在我的滑块中,如果一个滑块增加,其他滑块应该减少并为这些滑块编写自定义样式,并且不再采用这些样式。我编写了自定义样式,例如 .slider_class .ui-widget-content {... } 但它采用默认样式 .ui-widget-content {... }
drawSlider: function(elementId, sliderMax, sliderVal) {
$(".slider_class").each(function() {
$( this ).empty().slider({
range: "max",
min: 0,
max: sliderMax,
value: sliderVal,
step: 100,
slide: function(event, ui) {
// Update display to current value
$(this).siblings().text(ui.value);
var total = 0;
$(".slider_class").not(this).each(function() {
total += $(this).slider("option", "value");
});
total += ui.value;
var max = sliderMax - total;
// Update each slider
$(".slider_class").not(this).each(function() {
var t = $(this),
value = t.slider("option", "value");
t.slider("option", "max", max + value)
.siblings().text(value + '/' + (max + value));
t.slider('value', value);
});
}
});
});
// code for dynamically displaying the slider
$('#account-wrapper-holder').append('<div class="account-wrapper">' +
'<h6>' + aName[j] + ':' + aNum[j] + '</h6>' +
'<p><span id="text-tot-allocate-value' + aName[j] + aNum[j] + '">Current cash balance: $' + balanceRange[j] + '</span>' +
'<span>Total to allocate:<input type="text" id="tot-allocate-value' + aName[j] + aNum[j] + '" value="' + balanceRange[j] + '" onchange="s.setValue(parseInt(this.value))"/></span></p>' +
'<div class="slider_class" id="slider-' + aName[j] + aNum[j] + '"></div>' +
'<span class="value">0</span><span class="var-account-total-balance" style="float:right;">$0</span></div>'
);
_this.drawSlider('slider-' + aName[j] + aNum[j] + '', sumOfCurrencyBalances, balanceRange[j]);
I have a multiple jQuery slider and write custom style for that , in my slider if one slider increases the other sliders should decreases and write custom style for these sliders and its not taking those styles anymore. I wrote custom style like .slider_class .ui-widget-content {... } but it takes default style .ui-widget-content {... }
drawSlider: function(elementId, sliderMax, sliderVal) {
$(".slider_class").each(function() {
$( this ).empty().slider({
range: "max",
min: 0,
max: sliderMax,
value: sliderVal,
step: 100,
slide: function(event, ui) {
// Update display to current value
$(this).siblings().text(ui.value);
var total = 0;
$(".slider_class").not(this).each(function() {
total += $(this).slider("option", "value");
});
total += ui.value;
var max = sliderMax - total;
// Update each slider
$(".slider_class").not(this).each(function() {
var t = $(this),
value = t.slider("option", "value");
t.slider("option", "max", max + value)
.siblings().text(value + '/' + (max + value));
t.slider('value', value);
});
}
});
});
// code for dynamically displaying the slider
$('#account-wrapper-holder').append('<div class="account-wrapper">' +
'<h6>' + aName[j] + ':' + aNum[j] + '</h6>' +
'<p><span id="text-tot-allocate-value' + aName[j] + aNum[j] + '">Current cash balance:
+ balanceRange[j] + '</span>' +
'<span>Total to allocate:<input type="text" id="tot-allocate-value' + aName[j] + aNum[j] + '" value="' + balanceRange[j] + '" onchange="s.setValue(parseInt(this.value))"/></span></p>' +
'<div class="slider_class" id="slider-' + aName[j] + aNum[j] + '"></div>' +
'<span class="value">0</span><span class="var-account-total-balance" style="float:right;">$0</span></div>'
);
_this.drawSlider('slider-' + aName[j] + aNum[j] + '', sumOfCurrencyBalances, balanceRange[j]);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设你的标记看起来像这样,
在这种情况下,正确的 css 选择器将是
注意缺少空格。
如果不是这种情况,请发布您的标记。
编辑 jsFiddle
I am going to presume your markup looks like this,
In which case the correct css selector would be
Note the lack of a space.
If this is not the case, post your markup.
Edited jsFiddle