JavaScript Make DIVs move to corners of page when button is clicked

I have four DIVs to divide the page into four parts:

  1. top-left
  2. top-right
  3. bottom-left
  4. bottom-right

Now I want to create an animation using jQuery that triggers on button click, so that if user clicks, all four divs fade-out of the page, and to their respective corners like:

  • top-left div fades out to top-left corner of page
  • top-right fades out top-right and so on

I've found the explode method in jQuery but it's different from what I want.

Here is an image:

enter image description here

So if someone click the button, all four divs fade out to the corners of the page and, if clicked again reappear in their original position.

Here is what I do:

HTML

<div class="animate" style="float:left;">some text here</div>
<div class="animate" style="float:right;">some text here</div>
<div class="animate" style="top:50%; float:left;">some text here</div>
<div class="animate" style="top:50%; float:right;">some text here</div>

<button>Click here</button>

JS

$('button').click(function(e) {
   $(".div1").toggle( "explode" );
});

or

$('button').click(function(e) {
    $(".div1").fadeToggle(function()
    {
      $(this).animate({"left": "0","top":"0"});
    });
});

But they all fade out to one corner of the page. I don't know where the mistake is.

Answer:1

I'd like to figure out if a substring is within a string without using the Javascript built in methods of includes, indexOf, (any similar to those), or regular expressions. Basically just looking to ...

I'd like to figure out if a substring is within a string without using the Javascript built in methods of includes, indexOf, (any similar to those), or regular expressions. Basically just looking to ...

  1. find substring string c++
  2. find substring string python
  3. find substring string javascript
  4. find substring string php
  5. find substring string delphi
  6. find substring string
  7. find substring string java
  8. find substring string swift
  9. find substring string vb.net
  10. substring find string in sql server
  11. match substring string
  12. find substring in string js
  13. find substring in string matlab
  14. find substring in string r
  15. find substring in string excel
  16. find substring in string sql
  17. find substring in string vba
  18. find substring in string bash
  19. find substring in string jquery
  20. find substring in string python regex

I have an image . I want the image to be split into 100 pieces (outside the user will have appearance of 100 small images as a single large image) , and upon clicking each smaller image (ie any one ...

I have an image . I want the image to be split into 100 pieces (outside the user will have appearance of 100 small images as a single large image) , and upon clicking each smaller image (ie any one ...

I have two components: {{pc-sidebar}} {{pc-navbar action='toggleSidebar'}} Inside pc-navbar, i have a button that i want toggle an sidebar--active class: <button {{action 'toggle'}}>toggle ...

I have two components: {{pc-sidebar}} {{pc-navbar action='toggleSidebar'}} Inside pc-navbar, i have a button that i want toggle an sidebar--active class: <button {{action 'toggle'}}>toggle ...

I updated react-native to v0.57 and react-native run-ios is failing. I replaced babel-preset-react-native with metro-react-native-babel-preset as suggested in https://www.npmjs.com/package/babel-...

I updated react-native to v0.57 and react-native run-ios is failing. I replaced babel-preset-react-native with metro-react-native-babel-preset as suggested in https://www.npmjs.com/package/babel-...

  1. bundling failed error unable to resolve module
  2. bundling failed error fsevents unavailable
  3. bundling failed unable to resolve module
  4. bundling failed error while trying to resolve module