javascript object works on a html page but can not be loaded in wordpress
-
this piece of code works fine on a html page. (put in the header)
var startstop = new (function() { console.log('startstop called'); var $stopwatch, // Stopwatch element on the page incrementTime = 70, // Timer speed in milliseconds currentTime = 0, // Current time in hundredths of a second updateTimer = function() { $stopwatch.val(formatTime(currentTime)); currentTime += incrementTime / 10; }, init = function() { $stopwatch = $('.stopwatch'); startstop.Timer = $.timer(updateTimer, incrementTime, true); startstop.Timer.stop(); }; this.resetStopwatch = function() { currentTime = 0; this.Timer.stop().once(); }; $(init); });
When I try to access it on a WordPress page where this javascript is loaded in the header using a theme function console shows $(init) not a function.
What is wrong with this way of object declaration in WordPress?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘javascript object works on a html page but can not be loaded in wordpress’ is closed to new replies.