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

102
Views
Get a tags in tag p

I want to drop the code in a paragraph on every element it clicks on, but when I do that it returns [object html] to me.

How to display the tag in text (the tag itself)

document.addEventListener('click', function(e) {
    e = e || window.event;
    var target = e.target || e.srcElement,
        text = target.textContent || target.innerText;   
        document.getElementsByClassName("html-tag-element-picker")[0].innerHTML=target;
        
}, false);

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If i understand correctly you want to display the element tag a user clicks in your element, something like this? Or maybe you want everything, updated answer:

document.addEventListener('click', function(e) {
  e = e || window.event;
  var target = e.target || e.srcElement,
    text = target.textContent || target.innerText;
  document.getElementsByClassName("html-tag-element-picker")[0].innerHTML =e.target.outerHTML;
}, false);
span {
background: red;
}
p {
background: green;
}
<xmp class="html-tag-element-picker"></xmp>

<span>span el</span>
<p>p el</p>

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!