tags:

views:

59

answers:

3

I am using the jquery slider and using append() to update the value, but it will keep adding it unless I empty it on the start event. Is there a way where I can just updated the value instead of printing it out every time the action takes place. i tried replaceWith but no luck there.

   start: function(event, ui){
    $('#current_value').empty(); 
   },
   slide: function(event, ui){
    $('#current_value').fadeIn().append('Value is '+ui.value);

   },

Thanks,

Ryan

+1  A: 

If i understand you right, you should:

var existing = $('#current_value').html();
$('#current_value').html(existing + ui.value).fadeIn();
NTulip
+2  A: 

you need to use html() not append(), append adds the value at end of the given element, html sets the innerHtml for the given element.

$('#current_value').html('Value is '+ui.value).fadeIn();

MahdeTo
+3  A: 

You probably want something like

slide: function(event, ui){
    $('#current_value').text('Value is '+ui.value);
    $('#current_value').fadeIn();
}

text() documentation

matt b
Thank you for that. Works great so far. HTML also works too from what I see on the other answers. Just a different method?
Coughlin
As the documentation states: "Similar to html(), but escapes HTML (replace "<" and ">" with their HTML entities). Cannot be used on input elements. "
matt b