Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

86
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!