Jak sprawdzić, czy metoda .toggle() ukryła własnie element czy go pokazała?
Kod
$(this).children('ul').toggle(speed);//ukrywamy albo pokazujemyt dzieciaki
if ($(this).children('ul').is(":visible")) {
alert('ROBIMY ADD');
$(this).children('a').addClass('active');
} else {
alert('ROBIMY REMOWE');
$(this).children('a').removeClass('active');
}
if ($(this).children('ul').is(":visible")) {
alert('ROBIMY ADD');
$(this).children('a').addClass('active');
} else {
alert('ROBIMY REMOWE');
$(this).children('a').removeClass('active');
}
Powyższy warunek "is visible" zwraca mi zawsze true.
W czym jest problem? Czy problemem jest to, że nie odnosze się do tego elementu co trzeba?