How to add jQuery to a Bedrock project

Posted on 24 November 2016 at 13:30 by Wolfr_

First, install jQuery using npm:

npm install jquery

Then, go to content/js/index.js and add the following line:

window.$ = window.jQuery = require('jquery');

You can now write jQuery! Test it with the following code which will turn everything green:

$(document).ready(function() {
$('*').css('background', 'green');
});

Leave a Reply

Your email address will not be published. Required fields are marked *