you need to add 'http://www.w3.org/2000/svg'
to create the animation element like this
$(document).ready(function () {
var svg = $('svg').get(0),
square = svg.getElementById('red'),
animation = document.createElementNS('http://www.w3.org/2000/svg', 'animateMotion');
animation.setAttributeNS(null, 'id', 'walker');
animation.setAttributeNS(null, 'begin', 'indefinite');
animation.setAttributeNS(null, 'end', 'indefinite');
animation.setAttributeNS(null, 'dur', '10s');
animation.setAttributeNS(null, 'repeatCount', 'indefinite');
animation.setAttributeNS(null, 'path', 'M 0 0 H 800 Z');
square.appendChild(animation);
console.log(animation);
console.log(typeof animation.beginElement);
animation.beginElement();
});
also remove this line animation = svg.children[1].children[0].children[1];
so the animation element have the beginElement function
http://jsfiddle.net/2pvSX/1/