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

122
Vistas
Javascript function returning [object HTMLSelectElement] string instead of <select> HTML tag

I´m trying to create and call a function that builds a <select> item and returns this item to be rendered on the screen.

However, it renders the text "[object HTMLSelectElement]" on the screen instead of the <select> element that I want. In the Chrome console, though, it renders the <select> element perfectly.

function renderSelect(selectOptions) {
  var select = document.createElement("select");

  for (let index = 0; index < selectOptions.length; index++) {
    const element = selectOptions[index];

    select.insertAdjacentHTML(
      "beforeend",
      `<option value="${element}">${element}</option>`
    );
  }

  // This shows the <select> element perfectly in the console
  console.log(select)

  return select;
}

////////// BELOW IS THE FUNCTION CALL IN ANOTHER (WHICHEVER) PART OF THE CODE

// This renders "[object HTMLSelectElement]" on the screen instead of the <select> element
`${renderSelect(selectOptions)}`;
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