目的是写一把双管连接起来的支架(us)。
我现在说的是:
var $second_row = $( table tr:eq(1) ),
target_color = PaleGreen ,
original_color = $second_row.css( background-color );
$second_row.css( background-color , target_color);
scheduleOriginalColor();
function scheduleTargetColor() {
setTimeout(function() {
$second_row.css( background-color , target_color);
scheduleOriginalColor(true);
}, 500);
}
function scheduleOriginalColor(stop) {
setTimeout(function() {
$second_row.css( background-color , original_color);
if (!stop) {
scheduleTargetColor();
}
}, 500);
}
但是,它看着,我确信,有更好的写法。
任何建议?
var $second_row = $( table tr:eq(1) ),
target_color = PaleGreen ,
original_color = $second_row.css( background-color );
setRowColor(target_color, 500);
setRowColor(original_color, 1000);
setRowColor(target_color, 1500);
setRowColor(original_color, 2000);
function setRowColor(color, timing) {
setTimeout(function() {
$second_row.css( background-color , color);
}, timing);
}