HTML 代码:
<button id="go">Go</button><button id="stop">STOP!</button>
<div class="block"></div><button id="go">Go</button><button id="stop">STOP!</button>
<div class="block"></div>jQuery 代码:
// 开始动画
$("#go").click(function(){
$(".block").animate({left: '+200px'}, 5000)
})
// 当点击按钮后停止动画
$("#stop").click(function(){
$(".block").stop()
})
stop([clearQueue], [gotoEnd])
概述
停止所有在指定元素上正在运行的动画。
如果队列中有等待执行的动画(并且clearQueue没有设为true),他们将被马上执行
命令代码参考如下:# An R function to clear the screen on RGui:
cls <- function() {
if (.Platform$GUI[1] != "Rgui")
return(invisible(FALSE))
if (!require(rcom, quietly = TRUE)) # Not shown any way!
stop("Package rcom is required for 'cls()'")
wsh <- comCreateObject("Wscript.Shell")
if (is.null(wsh)) {
return(invisible(FALSE))
} else {
comInvoke(wsh, "SendKeys", "\014")
return(invisible(TRUE))
}
}
#cls() # test
# If you want to make sure that it worked (well, not 100% sure, but...)
res <- cls()
if (res) cat("Console should be cleared now!\n")