A
A
Andrey Reshetov2018-03-18 18:21:57
JavaScript
Andrey Reshetov, 2018-03-18 18:21:57

How to close a button normally?

$(document).ready(function() {
    $(".open-nav").click(function() {
    $('.nav').toggle(function(){
    $('.nav').css({'visibility': 'visible', 'display': 'table'});
 });
});
});


There is a code in jquery and it opens and closes the menu. But when closed, it doesn't close. I understand why this is happening. .css( ) always fires. But I don't understand how to fix it.

Ps: When opening, I need to ensure that these 2 properties work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stepan, 2018-03-18
@Renzi0n

Add an additional class where you insert rules like .visible{'visibility': 'visible', 'display': 'table'}
and already with toggleClass('visible') htibncz

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question