I'm using this code:
var s_wrap = document.getElementById('slider');
var s_list = document.getElementById('slider-list');
var li_items = s_list.getElementsByTagName("li");
var next = document.getElementById('next');
var pos, item_w, refreshIntervalId;
next.onclick = function() {
item_w = window.getComputedStyle(li_items[0],null).getPropertyValue("width").split('px')[0];
move('left', li_items[0], 10, item_w);
};
var move = function(direction, el, increment, amount) {
while(pos <= amount){
keep_moving = setInterval(function(){
pos = el.style[direction].split('px')[0];
if(pos == '') pos = 0;
pos = parseInt(pos) + increment;
el.style[direction] = pos + 'px';
}, 100);
}
clearInterval(keep_moving);
};
So basic gist of the code is, click a div, move a div left by 10 pixels at a time until it reaches 600px.
Now am I going about this the wrong way?
At the moment I get a
Uncaught ReferenceError: keep_moving is not defined