javascript - Why isn't my JS working (in wordpress)? -


what i'm trying have number count-up on page increases @ steady increment/interval. created stylized images represent each number 0-9 in count-up, need replace each number respective image. first function in code represents task, , second script actual count-up. i'm using wordpress i've added js file , enqueued in header.php file.

here's had problem: able count-up work, counterimages(input) function doesn't want work me. might issue how trying "call" on function on wordpress page.

if me out grateful!

function counterimages(input) { var output = ""  (var = 0; < input.length; i++) {     var chr = input.substring(i, + 1)     if (chr == '£') {         output += '<img border="0" src="img/pound.gif">';     } else if (chr == '.') {         output += '<img border="0" src="img/dot.gif">';     } else {         output += '<img border="0" src="http://eatiply3.staging.wpengine.com/wp-content/uploads/2013/05/'+(chr+1)+'.png">';     } return output; }  var start_date = new date("october 21, 2012 22:30:00"); // put in starting date here var interval = 1; // refresh interval in seconds var increment = 769.2;  // increase per tick (1/0.0013 ~ 769) var start_value = 35000; // initial value when it's start date var count = 0;  jquery(document).ready(function($) {  var msinterval = interval * 1000;  var = new date();  count = parseint((now - start_date)/msinterval) * increment + start_value;  $('#counter').html(count.tofixed(0));   window.setinterval( function(){     count += increment;      $('#counter').html(count.tofixed(0));  }, msinterval);  });` 

you missing bracket in counterimages function

http://jsfiddle.net/rhpjw/

function counterimages(input) {     var output = ""      (var = 0; < input.length; i++) {         var chr = input.substring(i, + 1)         if (chr == '£') {             output += '<img border="0" src="img/pound.gif">';         } else if (chr == '.') {             output += '<img border="0" src="img/dot.gif">';         } else {             output += '<img border="0" src="http://eatiply3.staging.wpengine.com/wp-content/uploads/2013/05/' + (chr + 1) + '.png">';         }         return output;     } }  var start_date = new date("october 21, 2012 22:30:00"); // put in starting date here var interval = 1; // refresh interval in seconds var increment = 769.2; // increase per tick (1/0.0013 ~ 769) var start_value = 35000; // initial value when it's start date var count = 0;  jquery(document).ready(function ($) {     var msinterval = interval * 1000;     var = new date();     count = parseint((now - start_date) / msinterval) * increment + start_value;     $('#counter').html(count.tofixed(0));      window.setinterval(function () {         count += increment;         $('#counter').html(count.tofixed(0));     }, msinterval); }); 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -