Как утверждать не нуль?

Чистый JavaScript:

var button = document.getElementById('button'); // Assumes element with id='button'

button.onclick = function() {
    var div = document.getElementById('newpost');
    if (div.style.display !== 'none') {
        div.style.display = 'none';
    }
    else {
        div.style.display = 'block';
    }
};

СМОТРИТЕ ДЕМО

jQuery:

$("#button").click(function() { 
    // assumes element with id='button'
    $("#newpost").toggle();
});

СМОТРЕТЬ ДЕМО

30
задан Louis 6 April 2015 в 10:49
поделиться