Take input value with jQuery

Asked

Viewed 243 times

0

inserir a descrição da imagem aqui

I’m trying to get the value of however, it returns me only the input.pgt as seen in the image above, already tried with . value and . val(), but still not working, follows the image of the code below:

inserir a descrição da imagem aqui

I need it to return the value that is in the field, instead of it returning me the value that the user wrote, it returns me the DOM element, for example: I typed, "Male", "Female", in each of the fields that contains the class "pgt", I want these two values to appear in the options array (which is present in Chrome’s console image), but instead of appearing "Masculine", "Feminine", it appears "input.pgt", "input.pgt"

inserir a descrição da imagem aqui

  • It is not clear what Leonardo wants to do, can provide us a verifiable example?

  • I just edited the question, make sure it’s more readable now, please.

  • Always put the code as text and formatted with the button {}

1 answer

-1

I managed to solve the problem, the problem was that when I used the .get() at the end of $.each, he took the DOM element instead of the value, so I decided to use the .map() in place of .each(), so it maps and returns me the value. Below is the corrected code.

inserir a descrição da imagem aqui

Browser other questions tagged

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