在我的jquery响应中有这样的内容:
...
success: function(data) {
$(".headline").replaceWith(function() {
return $(data).hide().fadeIn();
});
data
是什么样的:<h3 id="5" class="headline-content">Some headline </h3>
,我想知道如何滑动数据,使其看起来是从左边进入的?
发布于 2016-11-27 04:31:00
此解决方案使用JQuery和JQuery UI (用于幻灯片左边效果)。在这里,function test(data)
将是您的成功函数。replaceWith
是不必要的。
var d = "<h3>Some headline </h3>";
test(d);
function test(data) {
// Inject the result into the DOM element, but hide it at the same time
$(".headline").hide().html(data);
// toggle the visibility and animate the element coming in from the right
$(".headline").toggle( "slide", {direction: "right"});
}
.headline { font-size:2em;
width: 300px;
height: 2em;
background: #ccc;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type = "text/javascript"
src = "https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"></script>
<div class="headline"></div>
https://stackoverflow.com/questions/40825689
复制相似问题