I want to show alert using function in phtml file as per below but it seems like the function (myfunction) is not calling.
<button onclick="myFunction()">Try it</button>
<script type="text/javascript">
require(['jquery'], function($){
function myFunction() {
alert("I am an alert box!");
}
})
</script>