AntoLeNice Posted April 8, 2011 Share Posted April 8, 2011 Hi there, I had to make a slider bar to change the font-size of a website. The problem is: When I slide up, the text gets bigger, but when I slide down once, it gets bigger one more time before it starts getting smaller. When I slide down, the text gets smaller, but when I slide up once, it gets smaller one more time before it starts getting bigger. You know what I mean ?? The text should really follow the slider value to get its size, but it doesn't because of this. Here is the code I use for the slider: $(document).ready(function() { //get current font-size var current_font_size=$("#texte").css("font-size"); //add to attribute "title" $( "#slider" ).attr("title",current_font_size); current_font_size=parseInt(current_font_size); //create slider $("#slider").slider({ value: current_font_size, //size at the start orientation: 'horizontal', min: 10, //minimum size max: 20, //maximum size slide: function(event, ui) { //on slide var value = $( "#slider" ).slider( "option", "value" ); //getting the new value $("#texte").css("font-size",value); //modify css $("#slider").attr("title",value.toString()+"px"); //adding title to the handle $(".size").html(value.toString()+"px"); //show the new size } }); }); Thanks a lot, and I hope you can help me, Antoine Link to comment https://forums.phpfreaks.com/topic/233122-jquery-slider-that-changes-the-font-size-little-problem/ Share on other sites More sharing options...
AntoLeNice Posted April 8, 2011 Author Share Posted April 8, 2011 Problem resolved on another forum: I changed "$( "#slider" ).slider( "option", "value" )" for "ui.value", that was so simple -__-" Link to comment https://forums.phpfreaks.com/topic/233122-jquery-slider-that-changes-the-font-size-little-problem/#findComment-1198941 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.