有沒有辦法縮短這個感覺就像我在重複代碼,看起來很不整潔?重複的代碼
jQuery(document).ready(function() {
$('.allText').hide();
$('#b1').click(function() {
$('.allText').hide();
$('#text1').fadeIn(800);
});
$('#b2').click(function() {
$('.allText').hide();
$('#text2').fadeIn(800);
});
$('#b3').click(function() {
$('.allText').hide();
$('#text3').fadeIn(800);
});
$('#b4').click(function() {
$('.allText').hide();
$('#text4').fadeIn(800);
});
$('#b5').click(function() {
$('.allText').hide();
$('#text5').fadeIn(800);
});
$('#b6').click(function() {
$('.allText').hide();
$('#text6').fadeIn(800);
});
$('#b7').click(function() {
$('.allText').hide();
$('#text7').fadeIn(800);
});
});
你能分享相應的標記? – aletrasg 2013-03-05 15:45:05