我有一個修改後的Jquery UI滑動條(-100到+100)。當用戶向上和向下移動滑塊時,他們通過<div id="slider-result"></div>
在JQuery輸出中爲正數添加加號「+」
接收視覺反饋。當數字爲負數時,當前slider-result
顯示-
符號,例如, -47
,但它在數字爲正數時不顯示+
符號,例如, 61
我該如何讓slider-result
顯示+
符號緊挨在正數之前的數字?
I have looked at this question但是當我嘗試把它顯示+
當數爲正的解決方案集成,但它停止顯示數...
我嘗試
slide: function(event, ui) {
$("#slider-result").html(ui.value>0?'+':'') + ui.value;
任何幫助是一如既往,非常appriciated。由於
編輯 - 我的完整代碼
$('#submit').click(function() {
var username = $('#hidden').val();
if (username == "") username = 0; //SHOULD THIS STILL BE 0?
$.post('comment.php', {
hidden: username
}, function(return_data) {
alert(return_data);
});
});
$(".slider").slider({
animate: true,
range: "min",
value: 0,
min: -100,
max: +100,
step: 1,
slide: function(event, ui) {
$("#slider-result").html(ui.value>0?'+':'') + ui.value;
//this updates the hidden form field so I can submit the data using a form
if($(this).attr("id") == "one")
$("#hidden1").val(ui.value);
}
});
你可以發佈一個完整的代碼示例,以便我們能夠重現你看到什麼? – j08691
您是否檢查過輸出以確保缺少的數字不僅僅是在他們的div中被切斷? – bpeterson76