我有一个图像网格,我希望一次一个地闪烁一次。几年前,我在旧网站上使用了以下代码,并希望重用代码,但我无法在新网站上使用它。
$('document').ready(function() {
var myArray = ["img.square1","img.square2","img.square3","img.square4","img.square5","img.square6","img.square7","img.square8","img.square9","img.square10","img.square11","img.square12","img.square13","img.square14","img.square15"];
console.log(myArray)
var count = 15;
function counter() {
if(count < 16 && count > -1){
$(myArray[count]).fadeTo(100, 0.1, function(){
$(myArray[count]).fadeTo(100, 0.7, function(){
$(myArray[count]).fadeTo(200, 0.5, function(){
$(myArray[count]).fadeTo(500, 1);
count--
console.log(count);
});
});
});
}else{
clearInterval(myInterval);
//console.log("interval cleared");
}
}
//counter();
try{
counter();
alert('I guess you do exist');
}
catch(e){
alert('An error has occurred: '+e.message);
}
console.log(counter());
var myInterval = setInterval(counter(), 1100);
});
答案 0 :(得分:0)
您可以使用.fadeTo()
和setInterval()
回调代替function counter(selector) {
return $(selector).queue("images", $.map($(selector), function(image) {
// `next` is a reference to the next function in `queueName`: `"images"`
return function(next) {
return $(image).fadeTo(100, 0.1, function() {
$(this).fadeTo(100, 0.7, function() {
$(this).fadeTo(200, 0.5, function() {
$(this).fadeTo(500, 1, next);
});
});
});
}
})).dequeue("images").promise("images")
}
counter("img[class^=square]")
.then(function() {
console.log("done", this)
})
*** Settings ***
Library ExtendedSelenium2Library
Library ExcelLibrary
*** Testcases ***
Write Data in Excel
Open Excel D:\\01_Test_Cases\\testexcel.xls
Put String To Cell Sheet1 0 1 Test
Save Excel D:\\01_Test_Cases\\testexcel.xls