multiple .js files error: undefined
I'm trying to have multiple .js files. Each file will do specific tasks.
When I have the code in a single file all is good. But when I break the code up I get:
common.js
- $(function () {
$("#equationSubmit").click( function() {
var myTerm = getTerm();
// do work here
});
});
- var terms = [];
terms[0] = new term ( );
terms[1] = new term ( );
terms[2] = new term ( );
terms[3] = new term ( );
terms[4] = new term ( );
terms[5] = new term ( );
term.js
- var term = function ( ... ) {
// initialize code here
};
- term.prototype.displayText = function( text ) {
// do work
};
- term.prototype.visible = function ( ) {
// do work
};
I've tried to link them different way:
- <script src="js/mylibs/common.js"></script>
<script src="js/mylibs/term.js"></script>
- <script src="js/mylibs/term.js"></script>
<script src="js/mylibs/common.js"></script>
Can this be done?