您将如何改进这一点,这样我就不必继续重复了?我将需要创建 50 个选项。
var timer = 300;
function showLabels() {
$('#machine ul#labels li span').animate({'top': '0px'},'slow');
}
function option1() {
setTimeout(function() { $('#prize-details #prize-text h1').html("Header"); }, timer);
setTimeout(function() { $('#prize-details #prize-text p').html("Text here"); }, timer);
$('#machine ul#labels li#what').html('<span>1</span>');
$('#machine ul#labels li#where').html('<span>2</span>');
$('#machine ul#labels li#with').html('<span>3</span>');
$('#machine ul#labels li#in').html('<span>4</span>');
showLabels();
}
function option2() {
setTimeout(function() { $('#prize-details #prize-text h1').html("Different header here."); }, timer);
setTimeout(function() { $('#prize-details #prize-text p').html("Different text here"); }, timer);
$('#machine ul#labels li#what').html('<span>5</span>');
$('#machine ul#labels li#where').html('<span>6</span>');
$('#machine ul#labels li#with').html('<span>7</span>');
$('#machine ul#labels li#in').html('<span>8</span>');
showLabels();
}