I have a very simple html field
<input type="text" value="#123456" name="color">
And basic jQuery code to change the value
$(document).ready(function(){
$('input').val('#AAAAAA');
});
If I run this previous code, the display updates the value, but if I inspect the HTML element, it is still set to the old value. I have to do
$(document).ready(function(){
$('input').attr('value', '#AAAAAA');
});
to actually change the input value. I was under the impression that val()
would take care of updating the value if the input field has a name
attribute, but it does not.
Is this expected jQuery (3.4.1) behavior ?
Fiddle is here