To set the starting and ending values of the price slider to 0 and 2000 respectively, you can modify the slider function inside the code as follows:\n\njavascript\n$(function() {\n $("#slider-range").slider({\n range: true,\n min: 0,\n max: 2000, // Set the max value to 2000\n values: [0, 2000], // Set the values to [0, 2000]\n slide: function(event, ui) {\n $("#amount").html("$&quot; + ui.values[0] + &quot; - $&quot; + ui.values[1]);\n $("#min").val(ui.values[0]);\n $("#max").val(ui.values[1]);\n }\n });\n $("#amount").html(\n "$&quot; +\n $("#slider-range").slider(&quot;values&quot;, 0) +\n &quot; - $&quot; +\n $("#slider-range").slider(&quot;values&quot;, 1)\n );\n});\n\n\nTo add default values to the input fields and enable a popup to write numbers, you can use the following code:\n\njavascript\n$(function() {\n $("#slider-range").slider({\n range: true,\n min: 0,\n max: 2000,\n values: [0, 2000],\n slide: function(event, ui) {\n $("#amount").html("$&quot; + ui.values[0] + &quot; - $&quot; + ui.values[1]);\n $("#min").val(ui.values[0]);\n $("#max").val(ui.values[1]);\n }\n });\n\n // Set initial input field values\n $("#min").val($("#slider-range").slider(&quot;values&quot;, 0));\n $("#max").val($("#slider-range").slider(&quot;values&quot;, 1));\n\n // Add popup to handle selector\n $("#slider-range .ui-slider-handle")\n .each(function() {\n $(this).attr(&quot;data-value&quot;, $(this).slider(&quot;value&quot;));\n })\n .on(&quot;mousedown&quot;, function() {\n var handle = $(this);\n var popup = $("<div class='popup'></div>").appendTo(handle);\n $("<input type='number' class='popup-input'>")\n .appendTo(popup)\n .on(&quot;change&quot;, function() {\n handle.slider(&quot;value&quot;, $(this).val());\n handle.attr(&quot;data-value&quot;, $(this).val());\n });\n });\n});\n\n\nYou can then style the .popup class to position it correctly and add any additional styling you want.

jQuery UI Slider: Setting Default Values, Input Fields, and Popup for Handle Selection

原文地址: https://www.cveoy.top/t/topic/qfhM 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录