0

I've got an inline module script using other modules from a project. I need to call module functions from html using onclick or everything else working..

<script type="module">
   import * as blabla from './somemodule.js';

   function myfunction(){
      console.log("Youhou!");
    }

   //Communication from script to html works fine
   document.getElementById('test').onclick = myfunction;
</script>
<button id="test">Test</button>
<button onclick="myfunction();">Test</button>//This dont work

Is this even possible ? Cant find anything on google and I'm a good googler. Thank you very much !

J. Doe
  • 1

1 Answers1

-1
onClick="myFunction()"

or

jQuery('#clickable').click( myFunction() );

There is also VanillaJS solution for that...

getElementById('clickable').addEventListener('click', myFunction() )
azurinko
  • 261
  • 2
  • 11