1

我知道这个问题被问了 mnay 次,但我仍然无法解决它。如果您有任何想法,请告诉我。问题仅在 IE 中,单击按钮时根本不会滑动。

这是我的代码

JS:

$(document).ready(function($){
     $('#hide_cookie').click(function(e) {
      event.preventDefault()
      $('.cookie').slideUp('slow', function() {
        // Animation complete.
      });
    });
});

CSS:

.cookie {
    background: #47515c;
    text-align: center;
    color: #dadcde;
    max-height: 115px !important;
    zoom: 1;
}
.cookie span {
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
}
.cookie p {
    font-size: 11px;
    line-height: 14px;
}
.cookie .button {
    height: 37px;
}
.cookie .button a {
    color: #fff;
}

HTML:

<div class="cookie">
    <div class="container_12">
        <span>Title</span>
        <p>content here</p>
    </div>
    <div class="button">
       <a href="#" id="hide_cookie" class="read-more">Hide me</a>
    </div>
</div>

小提琴

4

4 回答 4

2

您作为 click 事件参数传递e,然后调用event. 试试这个:

$(document).ready(function($){
     $('#hide_cookie').click(function(e) {
      e.preventDefault()
      $('.cookie').slideUp('slow', function() {
        // Animation complete.
      });
    });
});

jsFiddle 示例

于 2013-04-04T16:35:09.623 回答
2

两个问题:

'slaw' 不是要传递给的正确速度值.slideUp(),请尝试 'slow'

您的事件函数使用“e”作为事件参数,然后将其称为event

$(document).ready(function($){
     $('#hide_cookie').click(function(e) {
      e.preventDefault()
      $('.cookie').slideUp('slow', function() {
        // Animation complete.
      });
    });
});
于 2013-04-04T16:36:33.243 回答
1

删除你的event.preventDefault(),因为在这种情况下它并不重要。

于 2013-04-04T16:36:26.853 回答
1

删除 event.preventDefault() :)

于 2013-04-04T16:38:10.677 回答