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

247
Views
How to insert <button> inside <li>from javascript

I need to put a button inline with text, like enter image description here

I am doing anything like:

    var list = document.getElementById('listaUnidadesCanjeadasAgregadas');
    var entry = document.createElement('li');
    var btnDlt = document.createElement('button');

    entry.appendChild(document.createTextNode(inputSerie.val()));
    list.appendChild(entry);

    btnDlt.className = "btn-delete btn btn-default btn-xs glyphicon glyphicon-trash";
    list.appendChild(btnDlt);

but its not the same because the image appears below the text enter image description here

Forget the blue backgroud, its not important! Thank you people.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

last line

 list.appendChild(btnDlt);

you are appending to the list instead of the entry

try

 entry.appendChild(btnDlt);
about 4 years ago · Juan Pablo Isaza Report

0

Try this way1

var list = document.getElementById('listaUnidadesCanjeadasAgregadas');
var entry = document.createElement('li');
var btnDlt = document.createElement('button');
btnDlt.className = "";//Class
list.appendChild(btnDlt);
entry.appendChild(document.createTextNode('valor'));
entry.appendChild(btnDlt);
list.appendChild(entry);
<div class="d-flex h-100">
  <ul id =listaUnidadesCanjeadasAgregadas>
   </ul>
</div>

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!