Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

263
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda