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

135
Views
Trigger touch event onclick

I have an element which works only ontouch(start), and I want to make that onclick will trigger ontouch (for non-touchable devices, such as my pc). like:

element.onclick = element.touchStart();

or:

element.onclick = element.touch();

Is something like this possible?

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

You need to create a new touch event using new Event, and dispatch it to the element, using dispatchEvent method of event.target.

let div = document.querySelector("div");

div.addEventListener("click", (e)=>{
  var event = new Event('touch');
  e.target.dispatchEvent(event)
});

div.addEventListener("touch", (e)=>{
  console.log("touched");
});
#test{
  background: red;
  width: 200px;
  height: 200px;
}
<div id="test"><div>

about 4 years ago · Santiago Gelvez 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!