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

260
Views
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
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!