Calling a jQuery function from another file
OK - I didn't think this was going to cause me such big headaches.
I have the following function:
- function getTimeStamp() {
- var now = new Date();
- return ((now.getMonth() + 1) + '/' + (now.getDate()) + '/' + now.getFullYear() + " " + now.getHours() + ':'
- + ((now.getMinutes() < 10) ? ("0" + now.getMinutes()) : (now.getMinutes())) + ':' + ((now.getSeconds() < 10) ? ("0" + now
- .getSeconds()) : (now.getSeconds())));
- }
Until this morning - the function resided in a page I was developing, and when I called it I got the desired results.
But - since I will want to use timestamps on other pages as well - I decided to put this function in a custom.function.js file and call it from there. I included the file in my <head></head> section. I'm calling the function the same way I always have ...
- $("#findTime").click(function() {
- var tmStamp = getTimeStamp();
- console.log("inside click: " + tmStamp);
- });
But now - I'm not getting ANYTHING returned. Do I have to call the function differently when I move it from the content page to custom functions file?
Thanks in advance - Pavilion