I'm developing a laravel application, there I want to set a onclick function to Html anchor element.
So I created it as following way.
In my blade view
<a class='compon' id="{{$value[1]}}" href="#" onclick="return myFunction();">
<div class="mq-friends thumbnail">
<div class="mq-friends-footer">
<small>{{$value[0]}}</small>
</div>
</div>
</a>
my resources/assets/js/app.js
function myFunction() {
console.log('whatever');
return true;
}
This is not working, (I also carefully checked that app.js file has built into public/js/app.js using laravel-mix (npm run dev) and the function myFunction() is there.)
What I want to know is why it is not working? is there any problem with blade?
Note: This is clearly working when I insert this script into my same blade view without adding to js file:
<script type='text/javascript'>
function myFunction()
{
console.log('whatever');
return true;
}
</script>