Please do not beat me a lot of code that is written below.
var flip = 0;
$('#btn').click(function () {
$('#blck').toggle( flip++ % 2 == 0 );
$('#menu-btn') .removeClass('close') .addClass('open')
});
The code I put together pieces of 2, he should perform the opening and closing div, while changing the class of another div.
The problem is that the class of the second object does not change back to the second click … As I understand it should be a condition IF. Help me understand the syntax of the language.
Many thanks in advance and sorry for bad english.
The question is closed. Thanks gillesc. Your suggestion did not work, I had to add:
var flip = 0;
$('#btn').click(function () {
$('#blck').toggle( flip++ % 2 == 0 );
$('#menu-btn').toggleClass('close open');
});
Now everything is in order
You don’t need a if, just toggle the classes, same for the block just toggle it.