Created
January 6, 2023 16:02
-
-
Save annelyse/02eb3d14ecb0088909883b46dd1a9252 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simulate a click event. | |
* @public | |
* @param {Element} elem the element to simulate a click on | |
*/ | |
var simulateClick = function (elem) { | |
// Create our event (with options) | |
var evt = new MouseEvent('click', { | |
bubbles: true, | |
cancelable: true, | |
view: window | |
}); | |
// If cancelled, don't dispatch our event | |
var canceled = !elem.dispatchEvent(evt); | |
}; | |
const falseClick = document.querySelector('.falseClick'); | |
if( falseClick ){ | |
falseClick.addEventListener('click', event => { | |
console.log( 'click' ); | |
const link = document.querySelector('#wp-live-chat-by-3CX'); | |
console.log(link ); | |
simulateClick(link); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment