There are two btn1 and btn2 buttons and there are two blocks: block1 (initially display: block;) and block2 (initially display: none;), I want to link them to this combination: so that when I click on the btn1 button: the first block is assigned display: none; and to the second block: display: inline-block; when clicking on btn2: the first display unit: block; second display: none; Not good at jquery, help with advice or an example. Thank.

  • Want to js without jquery? - Mr. Black
  • the main thing to work :) - sagan
  • the answer has already been given, izi) - Mr. Black

1 answer 1

$('.btn1').on('click', function(){ $('.block1').css('display','none'); $('.block2').css('display','inline-block'); }); $('.btn2').on('click', function(){ $('.block1').css('display','block'); $('.block2').css('display','none'); }); 
  • one
    How many extra gestures can be in one line: $(".block").toggleClass("hide-box") - Alex Krass
  • one
    The question was not strong in jQuery ... but explaining what a hard class is a little bit longer ... - Boris Runs
  • Well, you and the answer did not explain anything) Leave a comment, as it may be useful to someone, no more. - Alex Krass