Kind time of the day, in general such a situation has arisen, there are 3 buttons by pressing the button, a certain form field is opened, you need to click on the button the previous field that was openly hidden. Please tell me how to proceed in this situation.

$(document).ready(function () { $(".viber-btn").click(function(){ if(!$(this).hasClass('active')) { $(this).addClass('active'); $('.phone-number-viber').show(); } else { $(this).removeClass('active'); $('.phone-number-viber').hide(); } }); $(".whatsup-btn").click(function(){ if(!$(this).hasClass('active')) { $(this).addClass('active'); $('.phone-number-whatsup').show(); } else { $(this).removeClass('active'); $('.phone-number-whatsup').hide(); } }); $(".skype-btn").click(function(){ if(!$(this).hasClass('active')) { $(this).addClass('active'); $('.login-skype').show(); } else { $(this).removeClass('active'); $('.login-skype').hide(); } }); }); 

    1 answer 1

     $(".viber-btn").click(function(){ $(".active").not(this).removeClass('active'); $(this).toggleClass('active'); $('.phone-number-viber').toggle(); }); 
    • Thanks for the help, it helped a lot - Tianil