2
<div id = "Info">
    <p id = "Name">
   ......
</div>

<input type = "button" value = "Edit" id = "Edit_button">

<div id = "Edit">
    ....
    </div>

CSS :

#Info {
    display: block;
}

#Edit_button {
    display: none;
}

#Edit {
    display: none;
}

Функция ниже это callback при нажатии на кнопку выше.

 function main(){
    var info = document.getElementById("Info");
    var edit = document.getElementById("Edit");
    var edit_button = document.getElementById("Edit_button");
    alert("INFO" + info.style.display + " Edit" + edit.style.display + " Edit_Button" + edit_button.style.display);
    var json = document.body.json;
    if(info.style.display == "none" && edit.style.display == "block"){
        edit.style.display = "none";
        info.style.display = "block";
        edit_button.style.display = "block";
        waitForElements("Info");
        addJSONtoEdit(json);
    }
    if(edit.style.display == "none" && info.style.display == "block"){
        info.style.display = "none";
        edit_button.style.display = "none";
        edit.style.display = "block";
        waitForElements("Edit");        
        addJSONtoEdit(json);
    }
}

Проблема в том,я нажимаю на кнопку и в alert выводится -

введите сюда описание изображения

Соответственно,ни один из тех if-ов не срабатывает.

1 ответ 1

0
if(getComputedStyle(info).getPropertyValue("display") == "none" &&
   getComputedStyle(edit).getPropertyValue("display") == "block"){

Ваш ответ

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

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