Slide feedback down only if there's feedback and only once
I want a div that has the feedback of my application in it. What it needs to do is hide when there's no feedback and appear when there is feedback. But appear only once for the same thing.
So not constantly being slide down and hide, 开发者_StackOverflow中文版'cause that's the problem right now.
Here's what I got so far.
$("#book_container").mousemove(function() {
var feedbacklength = $(".feedback").text().length;
$(".feedback").hide();
if(feedbacklength == 2)
{
$(".feedback").hide();
}
else
{
$(".feedback").slideDown().delay(1500).slideUp(300);
}
});
You have an extra .hide()
outside of the if/else
blocks, so the feedback panel is hidden every time the handler function is executed; removing it should solve your problem:
...
$(".feedback").hide();
if(feedbacklength == 2)
{
$(".feedback").hide();
...
精彩评论