Supposing I have this input:
<input type="text" name="myInput" readonly>
How to get value from a readonly input with jQuery please ?
Thanks.
As usual, just select the element and get the value: $(":input[type=text][readonly='readonly']").val()
$(":input[type=text][readonly='readonly']").val('testvalue');
console.log($(":input[type=text][readonly='readonly']").val());
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="text" name="myInput" readonly>
You could simple use the selector for getting the value.In this solution i used name selector myInput.Hope this helps,thanks
var val = $( "input[name='myInput']" ).val() //Getting value using jquery name selector
console.log(val)
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="text" name="myInput" value="test" readonly>