Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

110
Visualizações
jquery code under hidden input field is not work when we get it using jquery

I have added the field and their jquery code to get the value for that field like

<input type='hidden' name="test" id="test" value="data=$('#response').val()">

I am getting that hidden field value in jquery and splitting it by '=' but when I alert the value it shows the $('#response').val() i am expecting it to return the value of the response field type.

var val = $("#test").val();
var arr1 = val.split('=');

alert(arr1[1]);

return => $('#response').val()

expected => value of responce field.

please let me know what i am doing wrong.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

in the value attribute there will be no javascript executed, it just contains the value of the input, see https://www.w3schools.com/tags/att_value.asp or compare to onclick attribute for example. There might be some parsing with alert, but it´s general knowledge not to debug any js with alerts.

you can just set the value attribute with javascript though

below your relevant markup you could do:

$('#test').val( $('#response').val() ); // will set the value

var expected = $('#test').val(); // will output the desired value then
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda