Value in input element is not displayed - (although value is being loaded correctly ) - Jquery

Asked

Viewed 235 times

2

Hello!

I am returning an object through ajax and assigning the values to the respective fields.

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

Using as example the title field:

$('#txt_titulo').val(objeto_menu.titulo);

However, I noticed something when I opened the browser console.

<input type="text" id="txt_titulo" class="form-control input-sm titulo lower valid" name="titulo" tabindex="4" autocomplete="off" placeholder="Título">

Although the field is correctly filled with the value coming from the server, I did not find in the element o value="Menu".

So I should find something like:

<input type="text" id="txt_titulo" class="form-control input-sm titulo lower valid" name="titulo" tabindex="4" autocomplete="off" value="Menu">

I’m altering some things at the front end, and I’m having a certain problem because I need this value.

Does anyone know why it’s not shown ?

  • This is correct, it is not displayed even on the console. Unless you have set the value attribute in your input. And you also don’t have to worry about it appearing or not pq every input has an attribute value and it’s la msm q vc n be seeing it on the console

1 answer

1


Just completing my comment.

If you want to see this attribute in the Console (This is not necessary).

You can do it:

$('#txt_titulo').attr('value', objeto_menu.titulo);

But the most common is to use it the way you did it and not worry about it not being visible on the console.

Because you can check the value of it this way:

$('#txt_titulo').val();

Browser other questions tagged

You are not signed in. Login or sign up in order to post.