2

I learned that function toggle() is deprecated. So what can i use instead toggle for this example:

<div id="block" style="width: 200px; height: 150px; background-color: blue"></div>

<span id="click">hide</span>

$("#click").toggle(
            function(){
               $("#block").slideUp();
               $(this).html('show');
            },
            function(){
               $("#block").slideDown();
               $(this).html('hide');

            });

http://jsfiddle.net/2rERJ/

Bakudan
  • 19,134
  • 9
  • 53
  • 73

1 Answers1

7

You can use click and slideToggle method.

$("#click").click(function(){
     var $block = $("#block"),
         $this = $(this);
     $block.slideToggle(function(){
         $this.text($block.is(':visible') ? 'hide' : 'show');
     });
});
ahren
  • 16,803
  • 5
  • 50
  • 70
Ram
  • 143,282
  • 16
  • 168
  • 197