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

112
Views
Obtener una etiqueta en la etiqueta p

Quiero soltar el código en un párrafo en cada elemento en el que hace clic, pero cuando lo hago, me devuelve [object html].

Cómo mostrar la etiqueta en texto (la propia etiqueta)

 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

Si entiendo correctamente, desea mostrar la etiqueta del elemento en la que un usuario hace clic en su elemento, ¿algo como esto? O tal vez quieras todo, respuesta actualizada:

 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!