Get value from a hidden input

0

I have a span that shows values from a range noUISlider, of that span I want to take the value it throws when I move the selector and store it to use it in a mathematical operation (multiply I divide by another value) and that result show it on the site

Reference image

It is seen that there is a minimum and maximum range, both values will have a conversion. As it is a WordPress plugin, I only have access to the following code generated in HTML:

<div class="price-slider price">
    <span id="price-value-min">9.350</span> 
    <span class="separator">UF </span>
    <span id="price-value-max">38.500</span>
</div>

<input type="hidden" name="price_min" id="min-value" value="9.350">
<input type="hidden" name="price_max" id="max-value" value="38.500">

The input values change when swiping, it's those values that I need to capture

I currently have this, but I can not show any value

jQuery(document).ready(function( $ ) {

    // $ Works! You can test it with next line if you like
    // console.log($);

    $('#price-value-min').click(function() {
        var x = $(this).val();
        // alert(x);

        // Recomiendo usar la consola en lugar de alerts
        console.log('El valor es: ' + x);
    });

});

It is worth mentioning that these values change

Thankful.

    
asked by Carlos Roman 15.01.2018 в 16:20
source

1 answer

2

Capture the value of max and min of the inputs after the input that sets the range changes:

$('#id_input_con_type_range').change(function(){  // si es una clase pondrias  .nombre_de_clase en vez de #id_d_input
      var min =  $('#min-value').val(),
          max = $('#max-value').val()
      console.log('maximo:',max,'minimo:',min)

})
  

Note: If you do not know where the html par is the input of type range , right click on the item, inspect item and look at your id .

    
answered by 15.01.2018 / 16:37
source