What is the variable firstClick ?

 $(document).ready(function ($) { $('.icon').click(function(){ $('.header, .content').addClass('active'); if ($('.sidebar').css('left')!=$('.sidebar').width()) { $('.sidebar').addClass('active'); var firstClick = true; // Скрипт который будет закрывать sidebar при клике на любое место $(document).bind("click", function() { if (!firstClick && $(event.target).closest('.sidebar').length == 0) { // Удаляем класс active $('.sidebar').removeClass('active'); // Удаляем класс active $('.header, .content').removeClass('active'); $(document).unbind("click"); } firstClick = false; }); } e.preventDefault(); }); }); 
  • Most likely for beauty, since unbind overlaps it. - Alex Krass
  • $(document).unbind("click"); ?! Well, you should have thought of this ... - Pavel Mayorov
  • And you can do without this variable? - user220055

0