Hide/Show on left side using jQuery

Anusha Honey

I want to hide/show a div on click. I want the div to go left to hide when I want it to hide. I have this. But the div goes up to hide. FIDDLE

$(document).ready( function() {
    $('#showmenu').click( function() {
       var hidden = $('.sidebarmenu').data('hidden');
       $('#showmenu').text(hidden ? 'Show Menu' : 'Hide Menu');
       if ( hidden ) {
           $('.sidebarmenu').css({
               position: 'absolute',
               left: -200000
           });
       } else {
           $('.sidebarmenu').css({
               position: '',
               left: 0
           });
       }
       $('.sidebarmenu,.image').data("hidden", !hidden);
    });
}); 

And this is my HTML

 <button id="showmenu" type="button">Show menu</button>
 <div class="sidebarmenu" style="position: absolute; left: -200000px">
     This should go left
 </div>
Greenhorn

Use animate() to show that it moves left

Edit:

If you want show the div initially:

Html:

<button id="showmenu" type="button">Hide menu</button>
<div class="sidebarmenu">
     This should go left
</div>

JS:

if(hidden){
        $('.sidebarmenu').animate({
            left: '0px'
        },500)
    } else {
        $('.sidebarmenu').animate({
            left: '-200px'
        },500)

css:

.sidebarmenu{
    position:absolute;
    left: 0px
}
    }

Demo Fiddle

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Left Floating side bar css- using jquery for scroll event

From Dev

jquery get width of div to left side window

From Dev

Using "is" operator with a default(T) on the left side

From Dev

Stack divs side by side without using float left

From Dev

Aligning logo on left side and nav items on right side using flexbox

From Dev

Aligning logo on left side and nav items on right side using flexbox

From Dev

Client side filtering using jquery

From Dev

jQuery show hide sliding panel from left side

From Dev

Jquery, animate div when mouse is near left side

From Dev

Jquery UI can't drag from left to right side

From Dev

Jquery, animate div when mouse is near left side

From Dev

delete element from left side of tandem_select_jquery_plugin

From Dev

Jquery ReferenceError: invalid assignment left-hand side

From Dev

jquery ui tab page with navigation bar on left side

From Dev

Rotate image left using swipe left in Jquery or Jquery Mobile

From Dev

DOT node with no left-hand-side using HQL with join

From Dev

How to display sub sub menu to the left side using CSS?

From Dev

ReferenceError: Invalid left-hand side in assignment using OR

From Dev

How to make a bundle of circle on the left side of the text using css

From Dev

How to Change Data from the right side to the left by clicking using EF

From Dev

Using the null-conditional operator on the left-hand side of an assignment

From Dev

When using IRB, what is the significance of the left side of the => operator?

From Dev

UIButton with image on left and right side using IBDesignable in Swift 3.0

From Dev

Mapping Left/Right side-buttons using xev

From Dev

Jquery each loop, find height of right side and add it to left side.

From Dev

div side by side and float left

From Dev

Is width required to float two divs side by side using float:left property?

From Dev

Client side filtration of data using jquery, knockout

From Dev

How to build side navigation using jquery

Related Related

  1. 1

    Left Floating side bar css- using jquery for scroll event

  2. 2

    jquery get width of div to left side window

  3. 3

    Using "is" operator with a default(T) on the left side

  4. 4

    Stack divs side by side without using float left

  5. 5

    Aligning logo on left side and nav items on right side using flexbox

  6. 6

    Aligning logo on left side and nav items on right side using flexbox

  7. 7

    Client side filtering using jquery

  8. 8

    jQuery show hide sliding panel from left side

  9. 9

    Jquery, animate div when mouse is near left side

  10. 10

    Jquery UI can't drag from left to right side

  11. 11

    Jquery, animate div when mouse is near left side

  12. 12

    delete element from left side of tandem_select_jquery_plugin

  13. 13

    Jquery ReferenceError: invalid assignment left-hand side

  14. 14

    jquery ui tab page with navigation bar on left side

  15. 15

    Rotate image left using swipe left in Jquery or Jquery Mobile

  16. 16

    DOT node with no left-hand-side using HQL with join

  17. 17

    How to display sub sub menu to the left side using CSS?

  18. 18

    ReferenceError: Invalid left-hand side in assignment using OR

  19. 19

    How to make a bundle of circle on the left side of the text using css

  20. 20

    How to Change Data from the right side to the left by clicking using EF

  21. 21

    Using the null-conditional operator on the left-hand side of an assignment

  22. 22

    When using IRB, what is the significance of the left side of the => operator?

  23. 23

    UIButton with image on left and right side using IBDesignable in Swift 3.0

  24. 24

    Mapping Left/Right side-buttons using xev

  25. 25

    Jquery each loop, find height of right side and add it to left side.

  26. 26

    div side by side and float left

  27. 27

    Is width required to float two divs side by side using float:left property?

  28. 28

    Client side filtration of data using jquery, knockout

  29. 29

    How to build side navigation using jquery

HotTag

Archive