0

I want to trigger an async event after a user clicks on a div, using below code

const fun = async (e) => {
   console.log('here');
   await myFunction();
}
$('#myDiv').click(fun);

I have this inside the <script> tag in the HTML with body

<div id='myDiv'>content</div>

but it doesn't trigger the function. If I change the code into

<div onclick="fun();">content</div>

the code works. Is there any way to do this with jquery?

kuco 23
  • 786
  • 5
  • 18

0 Answers0