There are two <input type="number" min="1" max="9"> . How to make the max attribute value for the second input equal to the current val() first input?
|
2 answers
$("#num1").on("change", function(){ $("#num2").attr("max", $(this).val()); }) <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type="number" id="num1" min="1" max="9"> <input type="number" id="num2" min="1" max="9"> |
$("#1").focusout(function() { $("#2").attr("max", $(this).val()); }) <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> input 1: <input id="1" type="number" min="1" max="9"> <br>input 2: <input id="2" type="number" min="1" max=""> |