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

107
Visualizações
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 Respostas
Responde à pergunta

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 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