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

163
Vistas
.click() on href javascript:void(0) results in undefined

I'm trying to make javascript auto click on a href link to show more data on the same page.

The Link has a javascript:void(0)

Code block:

document.querySelector("#showMoreHistory256 > a").click();
<div id="showMoreHistory256" class="showMoreReplies block" onclick="ecEvent.moreHistory(256, this, 0)
,lk,m"><a href="javascript:void(0);">Show more</a></div>

But I get the result Undefined in the console instead of the execution of the function "show more".

Is the querySelector or the .click() the wrong command for this?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try like this and you will not get errors:

var ecEvent = {
moreHistory: function (num,context,depth)
{
alert('The link was clicked programmatically');
}
};
var lk = false, m = false;
document.querySelector("#showMoreHistory256 > a").click();
<div id="showMoreHistory256" class="showMoreReplies block" onclick="ecEvent.moreHistory(256, this, 0)
,lk,m"><a href="javascript:void(0);">Show more</a></div>

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