开发者

hide() show() jquery

开发者 https://www.devze.com 2023-02-06 09:12 出处:网络
I\'m using the following: $(\'#info\').click(function (){ $(\'#message\').fadeIn(200).show(); return false;

I'm using the following:

$('#info').click(function (){ $('#message').fadeIn(200).show(); return false; });

How could I change my script so that it would dissapear once clicked apon again?

开发者_StackOverflow社区

Tried .fadeout().hide()

But it only show/hide so fast it looks as though nothing is happening.


$('#info').click( function(){
   $('#message').fadeToggle(200);
   return false;
});

to make it fade in and out.


You could try:

$('#info').click(
    function(){
       $('#message').toggle();
       return false;
    });

Using jQuery's toggle().


Edited to change from plain ol' toggle() to the slightly more in-keeping with the question fadeToggle():

$('#info').click(
    function(){
        $('#message').fadeToggle(400);
        return false;
    });

JS Fiddle demo, featuring fadeToggle().

There is, of course, also slideToggle(), which may be used similarly.


$('#info').click(function (){ $('#message').fadeIn(200).toggle(); return false; });

0

精彩评论

暂无评论...
验证码 换一张
取 消