+ 1
Can you write pure JavaScript and jQuery on the same .js document
2 Answers
+ 2
Yes you can write pure JavaScript and jQuery on the same .js document
+ 2
Yes! In your JavaScript file, use
$(document).ready(function(){
// your jQuery code here
});
to access JQuery.
Also, in your HTML file, youâll need to include a link to the jQuery library. You can download the file and place it in the same folder as your .js file and link it using <script src="jquery-3.3.1.min.js"></script>.
Or, Microsoft and Google host the jQuery libraries and you can include them without downloading the library by including <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> in the HTML file.
The W3Schools page also keeps an up-to-date reference for the jQuery host links in case they are updated or the links change. Hereâs a link to the page:
https://www.w3schools.com/jquery/jquery_get_started.asp