You don't just install jQuery using npm
and expect it work out of thin air, you also need to include it into your resources/js/app.js
file or whatever it's called and add that file to your blade template:
<script src="{{ asset(mix('js/app.js')) }}" defer></script>
After you've done this, you pick what you want to do next. Either add inline JS below the included script or add your code inside app.js
or in a separate file.
@geowrgetudor , thank you for responding. I have already included jquery in app.js like below
window.$ = require('jquery');
then, I run 'npm run dev' and put the app.js file in my layout file but still it's not working. below is the git repo where i have used this.
Does any of the following work in your app.js
? Do they output test
in the browser's console?
require('./bootstrap');
// case 1
$(document).ready(function() {
console.log("test");
});
// case 2
jQuery(document).ready(function($) {
console.log("test");
});
rajviahmedtamim liked this reply
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community