HTML Question

Javscript/html : Two input range field balance scale

How do i make this two input range field balance to maximum 100, that when move the first input field range the second should be adjusting too, vise versa. I mean that it should be proportional both sides like balance scale.

Here is my code https://jsfiddle.net/jsm4s2oz/1/

//First input range

<output name="judge_rangeOutput" id="judge_rangeOutput">75</output>
<input type="range" name="judge_range" id="judge_range" min="0" max="100" value="75" oninput="judge_rangeOutput.value = judge_range.value"><br/>


//Second input range
<output name="preJudge_rangeOutput" id="preJudge_rangeOutput">25</output>
<input type="range" name="prejudges_range" id="prejudges_range" min="0" max="100" value="25" oninput="preJudge_rangeOutput.value = prejudges_range.value ">


Please help

Answer

In your input handler, in addition to changing the <output> field for the same slider, also change the value of the other slider and the other <output> to 100 - this.value.

$("#judge_range").on("input", function() {
  $("#judge_rangeOutput").val(this.value);
  $("#prejudges_range").val(100 - this.value);
  $("#preJudge_rangeOutput").val(100 - this.value);
});
$("#prejudges_range").on("input", function() {
  $("#preJudge_rangeOutput").val(this.value);
  $("#judge_range").val(100 - this.value);
  $("#judge_rangeOutput").val(100 - this.value);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
First input range
<output name="judge_rangeOutput" id="judge_rangeOutput">75</output>
<input type="range" name="judge_range" id="judge_range" min="0" max="100" value="75">
<br/>Second input range
<output name="preJudge_rangeOutput" id="preJudge_rangeOutput">25</output>
<input type="range" name="prejudges_range" id="prejudges_range" min="0" max="100" value="25">