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

162
Views
.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 answers
Answer question

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