【问题标题】:Jquery hover animate with jquery ui dialogjQuery 悬停动画与 jquery ui 对话框
【发布时间】:2015-09-11 12:38:22
【问题描述】:

我有一个小而奇怪的问题,我的动画是用 jquery 和 jquery UI 实现的。您可以在下面看到一个简单的工作演示,

当您尝试单击窗帘中的“单击我”,然后在显示的弹出窗口中单击“关闭”时,问题就出现了。你会看到窗帘和图像都上升了。你知道为什么吗?

非常感谢

$(document).ready(function () {
    $('.box_product_image').hover(function () {
        $('.box_up-down', this).stop().animate({
            bottom: '0px'
        }, 300);
        $('.box_product_arrow', this).fadeOut(300);
    }, function () {
        $('.box_up-down', this).stop().animate({
            bottom: '-96px'
        }, 600);
        $('.box_product_arrow', this).fadeIn(300);
    });

    $(document).on('click', '#text', function () {
        $("#dialog").dialog({
            height: 200,
            width: 200,
            modal: true,
            closeText: "close"
        });
    });
});
*, ul, ol {
    border: 0 none;
    margin: 0;
    padding: 0;
}
.box_product_border_image {
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    height: 120px;
    overflow: hidden;
    width: 150px;
    margin: 50px;
}
.box_product_image {
    float: left;
    height: 120px;
    overflow: hidden;
    position: relative;
}
.box_up-down {
    background-color: rgba(0, 0, 0, 0.8);
    bottom: -96px;
    height: 100%;
    left: 0;
    position: absolute;
    width: 150px;
}
.box_up-down > * {
    color: #fff;
    font-size: 11px;
}
.box_product_name {
    font-weight: bold;
    margin: 3px 0 0 10px;
}
.box_product_arrow {
    height: 19px;
    position: absolute;
    right: 15px;
    top: 3px;
    width: 10px;
}
.box_product_desc {
    margin: 5px 0 0 10px;
}
.box_product_desc ul {
    font-size: 10px;
    line-height: 10px;
    list-style-type: none;
}
.box_product_desc ul li {
    margin-bottom: 6px;
}
.box_product_desc ul li a {
    color: #fff;
    text-decoration: none;
}
#dialog {
   background-color: rgba(0,0,0,0.5);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" type="text/css" rel="stylesheet">
<script src="https://code.jquery.com/ui/1.11.3/jquery-ui.min.js" type="text/javascript"></script>
<div class="box_product_border_image">
        <div class="box_product_image">
            <img width="150" height="120" src="http://www.microproject.com/wp-content/themes/NybergsMekVerstand/images/img03.png">
            <div class="box_up-down">
                <div class="box_product_name">Text</div>
                <div class="box_product_arrow" style="display: block;">
                   <img width="10" height="19" title="" alt="" src="http://tpgroupindia.com/images/arrow.png">
                </div>
                <div class="box_product_desc">
                    <ul>
                        <li>
                            <a href="#">Text</a>
                        </li>
                        <li>
                            <a href="#">Text</a>
                        </li>
                        <li>
                            <a id="text" href="#">Click me</a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
            
            
<div id="dialog"></div>

【问题讨论】:

    标签: jquery jquery-ui dialog jquery-animate


    【解决方案1】:

    我稍微重写了您的代码(jQuery、HTML 和 css),看看小提琴。 万恶之源可能是因为链接始终保持焦点..因此单击后可能需要对其进行模糊处理。

    http://jsfiddle.net/006L4uof/5/

    $('#text').on('click', function(e){
        $(this).blur(); //remove focus from clicked link
        $('#dialog').dialog({
            height: 200,
            width: 200,
            modal:true,
            closeText:"close"
            });
        });
    

    如果它没有按预期工作,请告诉我。

    【讨论】:

    • 谢谢!只需 $(this).blur(); 就可以完美运行 :) 再次感谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-16
    相关资源
    最近更新 更多