开发者

Slide feedback down only if there's feedback and only once

开发者 https://www.devze.com 2023-03-08 16:27 出处:网络
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.

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();
  ...
0

精彩评论

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