javascript - How to get slider value on click of button? -


i have range-slider has 2 ranges. want value of slider in javascript.

here have done:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>	  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>    <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">	  <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>    <script>        $(function() {    	$("#find_match").click(function(){          alert($('#amount').val(ui.values[ 0 ]));            });            $(function() {        $( "#slider-range" ).slider({          range: true,          min: 20,          max: 60,          values: [ 20, 30 ],          slide: function( event, ui ) {            $( "#amount" ).val( ui.values[ 0 ] + " - " + ui.values[ 1 ] );          }        });        $( "#amount" ).val( $( "#slider-range" ).slider( "values", 0 ) +                           " - " + $( "#slider-range" ).slider( "values", 1 ) );      });  </script>      <body>      <label for="amount">          age range:      </label>  	<input type="text" id="amount" readonly style="border:0; color:#f6931f; font-weight:bold;">  	<div id="slider-range"></div>          <button id="find_match">search matches </button>  </body>

in onclick() have done this; doesn't work out.

it says "ui not defined" in above code. want value of above slider on button click. how it?

note: slider not showing up.

you should use in onclick function:

var minage = $('#amount').val(); 

from documentation of .val(): if presented no arguments, .val() returns value of item. if presented 1 argument, .val(value) sets value of item argument provided.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -