Im trying to select all the li tags of the document and check if it hasClassName('yes')
so if it has, it will remove it. But im having a TypeError: Object [object HTMLLIElement], has no method 'hasClassName'
error.
This is the DOM method:
document.observe("dom:loaded", function() {
$(document.body).select('input').each(function(element) {
element.observe('click', function() {
init();
});
init();
});
});
The previous code will take the init fuction and check the if there are checked inputs and add them the 'yes' class name, but if I un-check those inputs, the class remains. This is the funcion that Im trying to do dynamic (add and remove class 'yes');
function init() {
$(document.body).select('input').each(function(element) {
if (element.checked) {
element.up('li').addClassName('yes');
}
if ($(document.body).select('li').hasClassName('yes')) {
element.removeClassName('yes');
}
})
}
Can you help me solving the last part of this function, so the removeclassname method will work? Thank you