简体   繁体   中英

change value in input field using radio button Jquery

I need to find a way to enable the input field with a value and change it or deactivate it with value 0

 $("#tax").value(19).prop("disabled",false); $("#tax").value(0).prop("disabled",true); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <label>tax %</label><br> <input type="radio" checked>Get tax <input type="radio"> No tax <input type="text" class="form-control" name="tax" id="tax" required=""> 

Update input box value on changing radio button

 $('input[name=taxs]').change(function (e) { $('#tax_value').val(e.target.value) }) 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <ul> <li><input type="radio" name="taxs" value="10"> 10</li> <li><input type="radio" name="taxs" value="20"> 20</li> <li><input type="radio" name="taxs" value="30"> 30</li> <li><input type="radio" name="taxs" value=""> No Tax</li> </ul> <input type="text" id="tax_value"> 

replace $("#tax").value(...

with $("#tax").val(...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM