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

99
Views
Function is executing inside button click automatically as default behavior

I have the code in below. There testFunction is executing automatically When the the button click is executing( default behavior of CMS I'm using. I want to override that behavior by skipping it in executing on button click). I want to skip executing the calling function named testFunction when the button click is executed. I tried below way without a success. Any input highly appreciated.


$(".classTest:not(selected)").find("button").on("click", function (){
      function testFunction(element,isSelected)
});

function testFunction(element, isSelected)(){ //code }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

One option might be to add a listener to an outer element (like the window), and on click, see if the target is one of those buttons - and if it is, call stopPropagation on the event to keep it from reaching the button.

window.addEventListener(
  'click',
  (e) => {
    if (e.target.matches('.classTest button')) {
      e.stopPropagation();
      // if you want something to happen when the button is clicked
      // put the code here
    }
  },
  true // add listener to capturing phase, not bubbling phase
);
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!