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

201
Views
Simulate click with javascript with no element ID
<button 
   type="button" 
   class="blue" 
   data-events="click:onAddNote" 
   data-events-target="cpoe-LabResultDetailView"
>
   Add Note
</button>

I'm trying to simulate / prompt a click of this button when I press a shortcut key sequence. However, I haven't been successful with anything other than through the class "blue", which works but also activates something else. How do I target the "data-events" or "data-events-target"?

Is there a way to something similar to: $("click:onAddNote").trigger("click");

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

0

Why not just this?

const button = docuemnt.querySelector('button')
button.click()
about 4 years ago · Juan Pablo Isaza Report

0

There are many ways to select the <button> element.

Method-1

In the example below, the click event is fired by selecting the first <button> element with the .blue class style applied.

let button = document.getElementsByClassName('blue');

button[0].addEventListener('click', function() {
  console.log("clicked");
});
<button type="button" class="blue">Add Note</button>

Method-2

The click event of the <button> element with the .blue class style applied using jQuery can be rendered as follows:

$(".blue").on('click', function(event) {
  console.log("clicked");
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<button type="button" class="blue" data-events="click:onAddNote" data-events-target="cpoe-LabResultDetailView">Add Note</button>

about 4 years ago · Juan Pablo Isaza Report

0

You can use querySelector and select the button with its attributes

var button = document.querySelector('[data-events="click:onAddNote"]');
button.onclick = ()=>console.log('Clicked');
button.click()
<button 
   type="button" 
   class="blue" 
   data-events="click:onAddNote" 
   data-events-target="cpoe-LabResultDetailView"
>
   Add Note
</button>

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!