Yes, I have both functions included in html. I know the ordering matters. What I'm confused about is the way that the JS functions are set up, and I don't know the right way to call the function I want.
For example, I have a Items.js
, in which I show some things on the screen, but I want to hide all of those items when the user activates something in a Phone.js
How Items.js
is set up:
Items = function()
{
this.stop = function()
{
// Items are hidden
$(this.ButtonDiv).hide();
$(this.CounterDiv).hide();
}
}
Now how do I call the stop function from Phone.js
?
Rather that declaring Items as a function try this:
var Items = {
stop: function() {
// Items are hidden
$(this.ButtonDiv).hide();
$(this.CounterDiv).hide();
}
}
And call the function like: Items.stop();
Items.js
must be loaded first. Inside Phone.js
you can call the function as:
Items.stop();
If that doesn't work (though I think it should), create a class instance of Items()
first and then call the stop()
method:
var items = new Items();
items.stop();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With