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

90
Visualizações
JSON.stringify gives something completely different
var tempid = document.getElementById("TDID1");

Using alert(JSON.stringify(tempid)) Gives

{"jQuery3600419938127216425761":{"events":{"click":[{"type":"click","origType":"click","data":null,"guid":14,"namespace":""}]}}}

When all i want it to give is a variable typeof sting with document.getElementById("TDID1")

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

0

JSON.stringify creates a string for the value you give it. When that value is an object, the string is JSON describing all of the own, enumerable properties of the object.

In your case, the object is a DOM element, and one on which jQuery has been used at some point.

When all i want it to give is a variable typeof sting with document.getElementById("TDID1")

If I understand you correctly, that's not what JSON.stringify is for. You could write the string directly of course:

const str = 'document.getElementById("TDID1")';

...but there's no way, starting from the value returned by getElementById, to construct a string for the way you accessed that value.

Or if you want the value of that element (assuming it's an input or select element), you could get that value from .value:

const value = document.getElementById("TDID1").value;

Or if you want the text content of a non-input element:

const text = document.getElementById("TDID1").textContent;

Or if you want the inner HTML of the element:

const html = document.getElementById("TDID1").innerHTML;

Or the outer HTML of the element:

const html = document.getElementById("TDID1").outerHTML;
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