0

how can i get and set slider value that is generated dynamically. i am using a range slider whose value i want to set and get but its html code is generated dynamically please point me in the right direction this is the code jsfiddle

this is what i tried so far .i get the value but unable to get when slider move how can i do this

var offsetY = $('#location-offsetY-slider').val();
alert(offsetY)
Anni
  • 142
  • 2
  • 16

2 Answers2

1

If you are using Bootstrap slider, use slide event:

$('#location-offsetY-slider').slider()
  .on('slide', function(ev){
       var offsetY = $('#location-offsetY-slider').val();
       alert(offsetY);
  });
Tony Dinh
  • 6,668
  • 5
  • 39
  • 58
0

HTML code generated dynamically still exists in the DOM, so you can access it the exact same way that you do with static html things. The only difference is that you may add a condition to make sure its here and put your "get" script after the dynamic creation.

I assume you are using the jQuery Slider: https://stackoverflow.com/a/11032004/2372008

Community
  • 1
  • 1
  • yes you are right but when i drag slider two are there values are changed now can i find out which one is change – Anni Mar 22 '14 at 19:50
  • Can you please correct your sentense? There seem to be some grammar problem that makes it hard for me to understand ... – Jean-François Gagnon Mar 22 '14 at 19:53
  • oops sorry actually the code is front of you please tell me how can i select those element who values are changed when i drag the slider – Anni Mar 22 '14 at 19:58