Support the ongoing development of Laravel.io →
JavaScript
Last updated 1 year ago.
0

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.

0

@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.

https://github.com/amitleuva1987/employee-management

0

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

1
Solution selected by @amitleuva1987

@geowrgetudor , Thanks for giving this tracing tricks. it's working.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.