Javascript jQuery在淡出时滑动
我在看jQuery API,他们有以下示例:Javascript jQuery在淡出时滑动,javascript,jquery,Javascript,Jquery,我在看jQuery API,他们有以下示例: <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>fadeOut demo</title> <style> span { cursor: pointer; } span.hilite { background: yellow; }
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>fadeOut demo</title>
<style>
span {
cursor: pointer;
}
span.hilite {
background: yellow;
}
div {
display: inline;
color: red;
}
</style>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<h3>Find the modifiers - <div></div></h3>
<p>
If you <span>really</span> want to go outside
<span>in the cold</span> then make sure to wear
your <span>warm</span> jacket given to you by
your <span>favorite</span> teacher.
</p>
<script>
$( "span" ).click(function() {
$( this ).fadeOut( 1000, function() {
$( "div" ).text( "'" + $( this ).text() + "' has faded!" );
$( this ).remove();
});
});
$( "span" ).hover(function() {
$( this ).addClass( "hilite" );
}, function() {
$( this ).removeClass( "hilite" );
});
</script>
</body>
</html>
淡出演示
跨度{
光标:指针;
}
白云石{
背景:黄色;
}
div{
显示:内联;
颜色:红色;
}
找到修饰符-
如果你真的想出去
在寒冷的天气里,一定要穿上
你的外套是我送给你的
你最喜欢的老师。
$(“span”)。单击(函数(){
$(this).fadeOut(1000,function(){
$(“div”).text(“'+$(this.text()+“'已褪色!”);
$(this.remove();
});
});
$(“span”).hover(函数(){
$(此).addClass(“hilite”);
},函数(){
$(此).removeClass(“hilite”);
});
这与我的代码类似。当短语被删除时,是否有办法使剩余段落向左滑动,以使过渡更平滑?我认为您必须设置p标记的动画。它是你点击的内容的父项,所以像这样的东西应该可以工作
$( this ).remove().parent('p').animate({
'margin-left' : '-500px'
}, 300);