How do you add jQuery in a JS file?
I have some code specific to sorting tables, and since the code is common across multiple pages, I want to create a separate JS file for it. All pages can reference this file.
The issue is: how to use jQuery in a JavaScript file and include the table sorter plugin as well.
I tried this approach:
You can use document.writeln
and add your source within.
eg: src: /javascripts/jquery.js" type="text/javascript"
To load table sorter you can use the below:
document.writeln
add your script src
like this : /javascripts/jquery.tablesorter.js
But it doesn’t seem to work.
What is the best way to properly include jQuery and plugins in a separate JavaScript file?