0

Помогите, пожалуйста, поправить скрипт

Хотелось бы чтобы после клика на #qwe все классы детей .active удалились (даже в ie7)

2 ответа 2

1
document.getElementById('qwe').addEventListener( "click" , function(e){

    for(var i = 0; i < this.childNodes.length; i++) {
        var child = this.childNodes[i];
        if(child.className)
            child.className = child.className.replace
      ( /(?:^|\s)active(?!\S)/ , '' )
    }

}, false);

http://jsfiddle.net/Tbskw/1/

1
  • всем спасибо. то что надо
    – cyklop77
    9 июл 2013 в 8:48
1

так? http://jsfiddle.net/Tbskw/4/

document.getElementById('qwe').addEventListener("click" , function(e){

    var childs = this.childNodes;

    for(var i=0; i < childs.length; i++) {

        if(/.*active.*/.test(childs[i].className)) {

            for(var i2=0; i < childs[i].childNodes.length; i2++) {
                childs[i].childNodes[i2].className = '';
            }  
        }
    }

}, false);

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.