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

261
Visualizações
HTML custom tags with Javascript: Cannot get HTML and text content between tags

I am creating some custom HTML tags using Javascript DOM manipulation, I have created a lot of them and they all work fine, except when they have to contain other tags. I am creating a tag called with the following syntax: <group label "(text here)"> (other tags here - for example some input fields)

Basically this single tag should replace the Fieldset / Legend coupled tags.

My code is the following:

var groups = document.getElementsByTagName("group");
for (var i=0; i<groups.length; i++) {
var label="",hhtml="<fieldset><br>";

if (groups[i].getAttribute("label") != undefined) 
label=groups[i].getAttribute("label");

var hcustomContent = groups[i].innerHTML + groups[i].textContent;


hhtml+="<legend>" + label + "</legend><br>" + hcustomContent + "</fieldset>";
groups[i].innerHTML=hhtml;
    
}

This does not work, and all the other tags i insert between my tags appear AFTER the fieldset box, instead of appearig inside. Anybody can point me to what i a doing wrong or correct my code? Thanks in advance.

about 4 years ago · Juan Pablo Isaza
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