S
S
Secret732018-03-12 16:48:06
css
Secret73, 2018-03-12 16:48:06

How to close the block that appears by clicking on it?

Good evening. There is such a code https://jsfiddle.net/enb8g6n8/12/ Its essence is to show or hide the block nicely and smoothly. Everything works as it should, with the exception of one moment:
1. How to close the block, when clicking on it, while maintaining the fadeOut animation?
2. I need to make 9 such blocks. Is there any more beautiful and shortened solution?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
Pavel Antonov, 2018-03-12
@Secret73

To switch the state of an element, use .fadeToggle()
Well, depending on the layout, you do If the hidden block comes after "Click me" Example

A
Andrew, 2018-03-12
@AndrewHaze

$( ".logistics" ).click(function() {
  if ( $( "#box" ).is( ":hidden" ) ) {
    $( "#box" ).fadeIn(1000);
  
  }
});

$( "#box" ).click(function() {
    $( "#box" ).fadeOut(1000);
});

D
Destell, 2018-03-13
@Destell

2. I need to make 9 such blocks. Is there any more beautiful and shortened solution?

Something like

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question