javascript - Creating multiple elements with different class names or IDs using jQuery -


i'm trying create multiple sliders different class names or ids using http://refreshless.com/nouislider/ individual value can used backend functionality. write new function different inputs each slider repeating myself. think might appropriate situation $(this) i'm not sure how use it. if done in handlebars.js make day.

noob question know, can seem find appropriate answer or tutorial through searches, due not knowing appropriate terminology.

here's create slider function:

this.prefslider = function () {      $(".prefslider").nouislider({         start: [50],         range: {             'min': 0,             'max': 100         }     });     $('.prefslider').link('lower').to($('.preflower'), 'text', wnumb ({         decimals: 0     })); } 

and here's html rendering it:

<div class="sliderbox">                                 <div class="prefslider">                                 </div>                                 <div class="slidervalues">                                     <span class="preflower"></span>                                 </div>                             </div> 

thank you

you can create multiple elements , call them id , not class

$("#slider1").nouislider({   start: [50],   range: {     'min': 0,     'max': 100   } });  $("#slider2").nouislider({   start: [50],   range: {     'min': 10,     'max': 50   } });  <div id="slider1" class="sliderbox">   <div class="prefslider"></div>   <div class="slidervalues">     <span class="preflower"></span>   </div> </div>  <div id="slider2" class="sliderbox">   <div class="prefslider"></div>   <div class="slidervalues">     <span class="preflower"></span>   </div> </div> 

Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -