I am calling a function on a click. The function has an if/else inside that checks the parent's className. On true I remove the class, on false I add a class. But it is only working in the first list item. It isn't setting the class edittable.
What could be the problem?
var editTask = function(elem) {
if (elem.parentNode.className !== 'edittable') {
elem.childNodes[0].innerHTML = 'Done';
elem.parentNode.className = 'edittable';
} else if (elem.parentNode.className === 'edittable') {
var setTask = elem.previousSibling.previousSibling.value;
var taskTarget = elem.previousSibling;
taskTarget.innerHTML = setTask;
elem.childNodes[0].innerHTML = 'Edit';
elem.parentNode.className = '';
}
}
You can see the live example here: http://www.baasdesign.nl/workspace/taskmanager/