现在我正在使用 scrollify 的当前部分(数据部分名称)在我的大纲中突出显示该部分(out-one,out-two 等)。
这显然是超级丑陋、重复和麻烦的,但它现在有效。我知道这可以写得更简洁,并且希望在简化它方面得到一些帮助!谢谢!
当前代码:
if($.scrollify.current().attr('data-section-name') === 'part-one-bee'){
$(".out-one").attr('style', 'font-size:24px!important;opacity:1;padding:10px;');
} else {
$(".out-one").attr('style', 'font-size:16px!important;opacity:.4;padding:0px;');
}
if($.scrollify.current().attr('data-section-name') === 'part-two'){
$(".out-two").attr('style', 'font-size:24px!important;opacity:1;padding:10px;');
} else {
$(".out-two").attr('style', 'font-size:16px!important;opacity:.4;padding:0px;');
}
if($.scrollify.current().attr('data-section-name') === 'part-one-three'){
$(".out-three").attr('style', 'font-size:24px!important;opacity:1;padding:10px;');
} else {
$(".out-three").attr('style', 'font-size:16px!important;opacity:.4;padding:0px;');
}
if($.scrollify.current().attr('data-section-name') === 'part-four'){
$(".out-four").attr('style', 'font-size:24px!important;opacity:1;padding:10px;');
} else {
$(".out-four").attr('style', 'font-size:16px!important;opacity:.4;padding:0px;');
}
if($.scrollify.current().attr('data-section-name') === 'part-five'){
$(".out-five").attr('style', 'font-size:24px!important;opacity:1;padding:10px;');
} else {
$(".out-five").attr('style', 'font-size:16px!important;opacity:.4;padding:0px;');
}
if($.scrollify.current().attr('data-section-name') === 'part-one-six'){
$(".out-six").attr('style', 'font-size:24px!important;opacity:1;padding:10px;');
} else {
$(".out-six").attr('style', 'font-size:16px!important;opacity:.4;padding:0px;');
}
if($.scrollify.current().attr('data-section-name') === 'part-seven'){
$(".out-seven").attr('style', 'font-size:24px!important;opacity:1;padding:10px;');
} else {
$(".out-seven").attr('style', 'font-size:16px!important;opacity:.4;padding:0px;');
}