Irene T.
Irene T.

Reputation: 1393

Adding dynamic elements

I am using the code bellow to use the Jquery UI Slider.

<script>
$(function() {
   $( "#slider" ).slider({
      value:100,
      min: 0,
      max: 500,
      step: 50,
      slide: function( event, ui ) {
         $( "#amount" ).val( "$" + ui.value );
      }
   });
   $( "#amount" ).val( "$" + $( "#slider" ).slider( "value" ) );
});
</script>

How can add multiple sliders with a button? I want to add slider elements when I click the button bellow.

<div id="adding"></div>

And how can I control them? This single slider has a jQuery code to work...

Upvotes: 0

Views: 35

Answers (1)

Barmar
Barmar

Reputation: 780798

$("#adding").click(function() {
    $("<div>").slider({
        // options
    }).appendTo("#sliderContainer");
});

Upvotes: 4

Related Questions