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 }
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
);