如果您愿意包括jQuery用户界面 http://jqueryui.com/库,除了 jQuery 本身,那么你可以简单地使用hide(),带有附加参数 http://docs.jquery.com/UI/Effects/Slide, 如下:
$(document).ready(
function(){
$('#slider').click(
function(){
$(this).hide('slide',{direction:'right'},1000);
});
});
JS 小提琴演示 http://jsfiddle.net/davidThomas/N98ee/.
无需使用 jQuery UI,您只需使用即可实现您的目标animate() http://api.jquery.com/animate/:
$(document).ready(
function(){
$('#slider').click(
function(){
$(this)
.animate(
{
'margin-left':'1000px'
// to move it towards the right and, probably, off-screen.
},1000,
function(){
$(this).slideUp('fast');
// once it's finished moving to the right, just
// removes the the element from the display, you could use
// `remove()` instead, or whatever.
}
);
});
});
JS 小提琴演示 http://jsfiddle.net/davidThomas/N98ee/1/
如果您选择使用 jQuery UI,那么我建议链接到 Google 托管的代码,网址为:https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.min.js https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.min.js