If I have this code in a file called custom.js:
var kennel = function(){this._init();};
kennel.prototype = {
_init: function() {
this.setListeners();
},
setListeners: function(){
...
},
getCats: function(){
alert("Get cats");
}
};
How do I call getCats() from some arbitrary html file?
First of all you would include the javascript by using the
<script>tag, generally in the<head>, then after that you can create another<script>tag which you can place your own javascript code in that is specific to the page, and which uses the functionality made available by the included file. For example:Also, the code you have posted has nothing to do with jQuery – it is plain old, vanilla javascript.