Reputation: 992
$("#storlekslider").slider({
range: "max",
min: 0,
max: 1500,
value: 0,
slide: function(event, ui) {
$("#storlek_testet").val(ui.value);
$(ui.value).val($('#storlek_testet').val());
}
});
// $( "#storlek_testet" ).val( $( "#storlekslider" ).slider( "value" ) );
$("#storlek_testet").change(function() {
$("#storlekslider").slider("value", $(this).val());
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="https://code.jquery.com/ui/1.9.0/themes/base/jquery-ui.css">
<div id="storlekslider"></div>
<input type="text" name="storlek" id="storlek_testet" value="500" />
Heres a js fiddle
im trying to get the slider to jump to the correct position when I change the value in the input field. Iam using the Jquery UI slider.
Upvotes: 17
Views: 48969
Reputation: 35039
You attach to the change
event of your input like so:
$("#storlek_testet").change(function() {
$("#storlekslider").slider("value", $(this).val());
});
Upvotes: 20
Reputation: 141
Change values from several inputs:
$("#input-1").change(function() {
$("#slider").slider('values',0,$(this).val());
});
$("#input-2").change(function() {
$("#slider").slider('values',1,$(this).val());
});
https://jsfiddle.net/brhuman/uvx6pdc1/
Upvotes: 10
Reputation: 754
$("#storlek_testet").keyup(function() {
$("#storlekslider").slider("value" , $(this).val())
});
Upvotes: 5