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; });
精彩评论